This prints an error message about qualifiers but don’t really understand what that means and how to adjust the code for it to work? Anyways, thanks a lot for looking at the code.
Note: The ostream operator is friended in the Node class.
using namespace std;
ostream& operator(ostream& output, const Node* currentNode)
{
return output;
}
void Node::nodeFunction()
{
//This node has items attached to the 'this' statement. After
//the necessary functions, this is called to output the items.
cout << this;
}
Your overloaded stream operator declaration should be like this:
You should be returning a reference to object of
std::ostream, the&is wrongly placed in your overloaded function prototype.Have a look at the working sample here.
Adding the source code here, for completeness.
Note: I have taken class
Nodemembers as public for ease of demonstration.