关于友元函数的实现的菜鸟问题!
#include<iostream>using namespace std;
class Y;
class Z;
class X
{
public:
X(int a=0){i=a;}
int geti(){return i;}
friend Z;
friend void Y::g(X*);
friend void h(X*);
private:
int i;
};
class Y
{
public:
Y(int b=1){k=b;}
void g(X*x1)
{
x1->i=x1->i+k;
}
private:
int k;
};
class Z
{
public:
Z(int c=5){t=c;}
void f(X*x2)
{
x2->i=x2->i+c;
}
private:
int c;
};
void h(X*x3)
{
x3->i=x3->i+10;
}
关于这段代码vc6.0编译时提示有一个错误:error C2027: use of undefined type 'Y'
see declaration of 'Y'
请问如何修改?谢谢了!