【问题标题】:invalid use of incomplete type (nested class case)不完整类型的无效使用(嵌套类案例)
【发布时间】:2013-04-29 12:51:43
【问题描述】:

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

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

【问题讨论】:

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


    【解决方案1】:

    这对我有用:

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

    【讨论】:

    • 对不起,我把我的情况过于简单化了,这里有点麻烦。请看一下我的问题的更新版本,提前谢谢。
    猜你喜欢
    • 2017-10-24
    • 2010-10-13
    • 1970-01-01
    • 2013-05-19
    • 2016-04-06
    • 2017-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多