What does this mean? Explanation needed.

Hey guys!
I'm studying for my c++ final and I need to know what this means.

EXAMPLE:

 
void display_flavor(string[], int[], double[], double [], int, string);


1.What does it mean when string[], int[], double[], double [], int, string is inside the parenthesis?

2.What does the blank brackets mean?

3.Why is there a string[] and a string without the [] at the end?

Thank you
Last edited on
Good question!

The '[]' mean it's sending in an array. So, string[] means that parameter is an array of strings, and string (without the '[]') is just a single string object.

You ignore everything @dhs2 said. Just a troll account.
Last edited on
Excuse my ignorance. So why use double [] twice?

Why did my professor use string [] and then string ? why wouldn't that single string object be include in
string [] ?
Last edited on
It might seem confusing. So let's take it one parameter at a time.

Firstly, a function can have any number of parameters, and they can be of any type, so you could send in three strings, or three integers, or whatever you want really.

void display_flavor(string[], int[], double[], double [], int, string);

First argument: string[]. This is an array of strings being passed to the function.

Second argument: int[]. This is an array of integers being passed to the function.

Third argument: double[]. This is an array of doubles being passed to the function.

Fourth argument: int. No '[]' here. This is just a single integer being passed to the function.

Fifth argument: string. No '[]' here. This is just a single string object being passed to the function.

Your professor did that because they wanted to send an array of strings "for whatever reason" and then also send a single string in a different parameters. There are a few reasons why you might want to do that. The array could be an array of student names. The single string could be the professor's name. You wouldn't really want them mixed up.
@JayZom Thank you so much. I finally get it. Really appreciate it!
Glad I could help. Feel free to drop any other questions you have our way and we'll do our best to help out.
Topic archived. No new replies allowed.