|
프로그램에서 특정 클래스의 멤버 함수를 friend로 선언 할려하는데 에러가 납니다. 어데서 잘못 되었지요?
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
class Y;
class X
{private:
int num;
public:
X()
{ num = 1;
}
friend void Y::add(X&);
};
class Y
{private:
int num;
public:
Y()
{ num = 2;
}
void add(X& x)
{ num += x.num;
}
};
int main()
{ X x;
Y y;
y.add(x);
return 0;
}
그럼
|