当我尝试执行此操作时遇到编译错误
struct Child{
char Name[8];
Parent *P;
};
struct Parent{
char Name[8];
Child *C;
};
编译器提示它无法在 struct Child
中找到 Parent,但交换它们的顺序没有帮助。编译器会提示它无法在 Parent
中找到 Child
。我如何解决这个错误,为什么我在编写程序时没有突出显示错误。
最佳答案
您可以添加 forward declaration :
struct Parent; //forward declaration
struct Child{
char Name[8];
Parent *P;
};
关于c++ - 结构的排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22063079/