Just for the sake of it, let's replace structure
with char
(for the moment), since I think you have also some troubles with the type structure
. Then we have a function like this:
char *readThingsFromFile(char *arrayOfThings, int &arraySize)
{
// Some Code
}
The first char *
describes the type of the return value from your function readThingsFromFile
.
The return value is the value you pass to the function-caller, when you close your function. This is what you usually see in Code as return var;
In your particular case, this return value is from the type char *
. The *
determines it as a pointer, so when the function closes it returns a character-pointer.
Next, there are your two function arguments:
char *arrayOfThings
:
Obviously, this is also an character pointer, only that at this point it's an function argument, which means you have to supply it to the function.
int &arraySize
:
The &
determines the required parameter as a so called reference (in this case to an integer). Reference means, that the functions expects a normal variable (here: just a normal integer, no pointer), but it will treat it as a reference, which means that internally it actually just uses your original variable. This is important for you to know, since this means that changes to the variable in your function are global and not only local in the function itself (remember: when you pass normal parameters to a function you can just change them, without seeing any of that in the calling function).
Now to come back to structure
- regarding the *
and &
operators, it behaves the same for structure
as it would do for char
or int
(it's just a pointer/reference to a structure theN).
The structure
itself just reprents a data type in this case.