hope everyone is staying safe. I just want to understand what's inside the parenthesis of the vote function in pset3 - Tideman:

bool vote(int rank, string name, int ranks[])

What does it mean to have the int rank, string name, int ranks[] in this order of the function?

An input of rank and input of name feed into the ranks array?

thanks, sorry if the question is silly.

1 Answer 1


No such thing as a silly question. It just means that you haven't learned it yet. That's all. ;-)

This is a function "signature". It defines what is expected to be passed to the function. int rank means that the first parameter must be an int, and the var name rank is used inside the function. This should not be confused with vars anywhere else, such as in main, called rank (unless there's a global variable with that name. Then it gets interesting!) They are not the same. Similarly, the second parameter must be a string and will be called name inside the function. Finally, the third parameter is an int array called ranks.

Oh, and boolin this case means that the function will return a bool value.

Any questions? ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thanks a lot <3
    – ZeevKeane
    Commented May 23, 2020 at 8:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .