不完整类型的无效使用(嵌套类情况)

yau*_*ser 3 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();
};
Run Code Online (Sandbox Code Playgroud)

n. *_* m. 5

这对我有用:

struct A {
    class B;
    B fun();
    class B {
        friend B A::fun();
    };
};
Run Code Online (Sandbox Code Playgroud)