我在同一个.cpp上有两个类:
// forward
class B;
class A {
void doSomething(B * b) {
b->add();
}
};
class B {
void add() {
...
}
};
Run Code Online (Sandbox Code Playgroud)
前进不起作用,我无法编译.
我有这个错误:
error: member access into incomplete type 'B'
note: forward declaration of 'B'
Run Code Online (Sandbox Code Playgroud)
我正在使用clang编译器(clang-500.2.79).
我不想使用多个文件(.cpp和.hh),我想在一个.cpp上编码.
我不能在A班之前写B班.
你有什么想法解决我的问题吗?
最好的祝福.