class a {
public:
void f2(b * elem);
};
class b {
public:
void f1(a * elem);
};
这里会有问题。
void f2(b * elem);
如何b
以可以使用函数的方式声明类f2
?
告诉编译器有一个类a和b。但是不要告诉他/她它们的外观:)可能是因为您使用了指针。对于编译器来说,它只是一个整数。稍后,您可以定义类的所有功能,现在编译将很高兴知道它们的外观。
class a; // tell the compiler there is a class a
class b; // tell the compiler there is a class b
// real implementation of class a
class a {
public:
void f2(b * elem);
};
// real implementation of class b
class b {
public:
void f1(a * elem);
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句