i have the following classes:
class mypipe {
class node {
public:
char ch;
node* next;
node(){...}
node(char c){..}
} ;
public:
unsigned int size;
node* head;
and i need to overload the operator<<, to print the mypipe as it is now.
then, i'm trying to write the following:
friend ostream& operator<< (ostream& stream, mypipe p) {
node* curr = p.head -> next;
...
immediately after the variables definition.
the problem is that i开发者_JAVA百科 get an error "identifier node is undefined". i've tried to declare the operator and implement it outside of the class, that didn't help.does anyone have any ideas about it?
thanks in advance for anyone who can help :)node
is an inner class, which means you have to qualify its type:
mypipe::node* curr = p.head -> next;
精彩评论