且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

类在名称空间错误中不存在

更新时间:2022-01-18 02:46:52

停止交叉包含头文件,您会很好的.例如,将声明放在一个头文件中.

您还需要转发类声明.例如:

Stop cross-include of your header files and you will be fine. Put the declarations in one header file, for example.

You also need forward class declaration. For example:

ref class BBB;
public ref class AAA {
    BBB^ bbb;
    //...
};

public ref class BBB {
    AAA^ aaa;
    //...
};



如果您不使用按值语义的实例的类引用,将是不可能的,这有明显的原因:由于无限的构造函数递归,实例化将导致无限的构造.

—SA



It won''t be possible if you used not class references by the instances in by-value semantic, by obvious reasons: instantiation would cause infinite construction due to infinite constructor recursion.

—SA