一个内部类的问题,希望大家给指点哪错了?
#include<iostream.h>class In;
class Out
{
public:
Out();
void fun(Out::In &);
class In
{
public:
In();
void fun(Out &);
friend Out;
private:
int i;
};
friend In;
private:
int i;
};
Out::Out()
{
i=10;
}
void Out::fun(Out::In &a)
{
cout<<"Out's i="<<i<<endl;
cout<<"In's i="<<a.i<<endl;
}
Out::In::In()
{
i=100;
}
void Out::In::fun(Out &a)
{
cout<<"In's i="<<i<<endl;
cout<<"Out's i="<<a.i<<endl;
}
int main()
{
Out a;
Out::In b;
a.fun(b);
b.fun(a);
return 0;
}