이런식으로 friend정의를 클래스 밖에서 하면
[code:1]
#include<iostream>
using namespace std;
class tri {
private :
int x;
int y;
public :
tri (int a,int b)
{
x = a;
y = b;
}
friend ostream operator<< (ostream os,tri m);
};
ostream operator<< (ostream os,tri m)
{
os << "x= " << m.x << " y = " <<m.y << endl ;
return os;
}
void main()
{
tri a(10,20);
tri b(30,40);
cout << a << b;