'friend' not permitted on data declarations

closed account (Lv0f92yv)
I see this error when trying to overload the << operator in one of my classes.

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
class Node {

public:
	friend ostream& operator << (ostream& output, const Node& n);

	int _val;

	//methods
	Node();
	Node( int );
	~Node();
	int getVal();
	void setVal( int );
};

...

ostream& operator<<(ostream& output, const Node& n) {
    output << "NODE::"<< n._val << "\n";
    return output;  // for multiple << operators.
}


I am using MSVC++2010 Express.

I have googled on this, and saw something about misplaced includes causing this, but I am not sure how to resolve this or what role misplaced includes would play.

Thanks for any help...
try with std::ostream
closed account (Lv0f92yv)
Ugh I am so terrible...

Thanks...

Desh
Topic archived. No new replies allowed.