struct and pointers

how do i read this

voin inserimento(Nodo * &testa, int numero)

{
whatever is here

}

i mean what is testa? a pointer of type nodo? can a declaration be done like that??? notcice the ampersand sign infront of testa? that is making sooo confused but the main code is working fine..soo am the ignorant one here...pls dont tell me to go and read on pointers been doing that for sometime now...some one pls just explain... Nodo * testa; is fine..declaring a pointer called testa of type testa..but Nodo * &testa, in the parameter of the function inserimento...is making me go nuts...help pls...
http://cplusplus.com/doc/tutorial/functions2/
The argument is passed by reference, that means that you want to change the pointer in order to change what it points to.
By instance in your code you may have
testa = new Nodo(numero);

I don't like it, prefer to return the address.
closed account (zb0S216C)
donfire wrote:
"i mean what is testa? a pointer of type nodo?"

It's a reference to a pointer to a "Nodo". And yes, it's a perfectly valid declaration. Such a declaration is used when the function needs to directly modify the pointer that was passed to function. In addition, a reference to a pointer prevents the calling function from passing the address of a variable/object when it expects and actual pointer. In C, the equivalent declaration was a pointer to a pointer.

Wazzak
thank you soo much...ne555 you made me woke up from my slumber...thanks...thank you too Framework!!!
Topic archived. No new replies allowed.