【发布时间】:2011-11-05 10:42:59
【问题描述】:
class two;
class one
{
int a;
public:
one()
{
a = 8;
}
friend two;
};
class two
{
public:
two() { }
two(one i)
{
cout << i.a;
}
};
int main()
{
one o;
two t(o);
getch();
}
我从 Dev-C++ 收到此错误:
a class-key must be used when declaring a friend
但使用 Microsoft Visual C++ 编译器编译时运行良好。
【问题讨论】:
-
呃,你能修复一下格式吗!我试过了,但是太难了。
-
请你修复你的空白。
-
请注意,不要使用 Dev-C++,它已经过时了。
标签: c++ visual-c++ dev-c++ friend-function