【发布时间】:2020-04-19 10:58:36
【问题描述】:
我有两个结构:
struct B;
struct A {
B *b;
void Func() {
std::cout << b->x << std::endl;
}
};
struct B {
A a;
float x;
void Func() {
a.Func();
}
};
当我尝试编译时,出现以下错误:
Error C2027 use of undefined type 'B'
Error C2227 left of '->x' must point to class/struct/union/generic type
我该如何解决?
【问题讨论】:
标签: c++ struct circular-dependency