<分区>
我在两个不同的文件中定义了以下两个类:
#include "B.h"
class A {
public:
A() {}
~A() {}
f() {
auto b = new B(this);
}
};
在另一个文件中:
#include "A.h"
class B {
public:
B(A* a) {}
~B() {}
}
但我不明白我得到的编译错误:
B.h: error: ‘A’ has not been declared
A.cpp: error: no matching function for call to ‘B(A&)‘
*this);
note: candidate is:
note: B(int*)
note: no known conversion for argument 1 from ‘A’ to ‘int*’
为什么我的 A 类已经转换为 int 了?!