Question

I have the following source code with a compiler error. Its obvious what I'm trying to do so I won't try explaining besides by saying that the type node<N>* being returned is not the correct type because it is a template and thats creating a conflict with the session* object. Heres the error.

linked_list_1.cpp|17|error: cannot convert 'node<session*>*' to 'session*' in assignment|
Was it helpful?

Solution

In line 17, you want to assign the return value of return_node to a session*, but the return type of return_node is a Node<N>* (Node<Session*>*) and not a N (session*). Add an accessor function to the node class, and use it to access the data member, e.g:

session* SESSION_COPY;
SESSION_COPY =  LIST->return_node(0)->getData();

OTHER TIPS

Because the return_node function returns node<N>* and not N. Or when N is substituted with the template argument: return_node returns node<session*>* (look in the header file) but you try to assign the returned pointer to a session* variable. Just like the error message very clearly says.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top