문제

how can I implement such an idea in C++ without getting into "invalid use of incomplete type" trouble?

class A {
    /*(...) some fields and methods here. */
    class B {
        /*(...) some fields and methods here. */
        friend B A::fun();
    };
    B fun();
};
도움이 되었습니까?

해결책

This works for me:

struct A {
    class B;
    B fun();
    class B {
        friend B A::fun();
    };
};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top