Behind the scenes of passing pointers as parameters

I've recently used this kind of notation to state that the function takes a pointer as a parameter.

void write(string* &word)

but I don't quite understand the theory behind it.
I've always thought that passing parameters to a function and the parameters mentioned in the function header combined to form a definition - kind like this:
***
1
2
3
4
5
6
7
8
void writeNumber(int number)
{//}
int main()
{
writeNumber(2);
return 0;

}


Combining, you get a defintion:
int number = 2;
***


but I don't understand how this would explain
string* &word = stringPointer.
Could someone please explain it??

I hope my question makes sense.
Last edited on
The line you posted is a valid definition.
This is a reference to a pointer.
Do you understand what string& word = some_string; is?
I understand references and I understand pointers. I never bothered with reference to pointers and pointers to pointers because it seemed a little too much.

I think i understand that line though: a string's memory address is stored in the variable word?? Is that correct?
The string's memory address is stored in stringPointer.
I believe the variable word is an alias for the string pointer stringPointer. So I guess nothing is actually stored in the variable word.
Last edited on
T& is is just T*const with nicer syntax.
Topic archived. No new replies allowed.