in a link list program i wanna send the new node pointer to a insert func so it can insert it into the list of nodes.
i have some other functions too, like delete, create node, insert, navigate and ...
any one get and return pointers. i used this syntax but it's not working
1 2 3 4 5
person insert(person &cp,person &pp,person &sp)
{
//work with cp,pp,sp
return cp;
}
and i call the function like this:
insert(cp,pp,sp);
what should i do?
cp -> current node pointer
pp -> previews node p
ssp -> start node p
I've noticed a few things that're easy to fix. Firstly, functions cannot be declared within a scope of another function. They need to be declared globally. For example:
A function that omits the body during its declaration is called a Prototype Function. These are required in C++. I'll provide a link regarding this.
Secondly, a function that has a return type-specifier of void cannot return anything. However, if it was a void pointer, then that's OK. A void pointer basically means that it can point to anything but the data it's pointing to is unknown.
Thirdly, your function, test( ), is ambiguous. This means that the compiler cannot decide which version of test( ) to call.