I am trying to understand what that means
I know that declares a variable to an address of type node and that & gets the address of a variable. I also know that in a function parameter it is a call by reference pointer. But I have never seen it in a variable declaration before…
What does it mean exactly
Node *&ptr = root->mRight
I know about working with pointers and everything I am mostly asking about the Node *& variable type.
Thanks!
On the right,
rootis a pointer to a node.root->mRightis a member of that node, namely itsmright, which is another pointer to a node.On the left, we declare something (before assigning a value to it with
=). If it wereNode *ptr, it would be a pointer to a node, but because of that&, it is not such a thing in its own right, it is only a reference, an alias of another such thing that already exists. Soptris just another name for the pointerroot->mRight.