无效使用不完整类型(嵌套类案例)

时间:2013-05-05 17:53:15

标签: c++ forward-declaration incomplete-type

如何在C ++中实现这样的想法而不会陷入“无效使用不完整类型”的麻烦?

class A {
    /*(...) some fields and methods here. */
    class B {
        /*(...) some fields and methods here. */
        friend B A::fun();
    };
    B fun();
};

1 个答案:

答案 0 :(得分:3)

这对我有用:

struct A {
    class B;
    B fun();
    class B {
        friend B A::fun();
    };
};