How to use class function in C ++?

I get a error: 'func' does not name a typewhen a member function of the funcclass Btries to return the class C:

class A {
    public:
        class B {
            public:
                C func() const {
                    ...
                }
            private:
                friend class A;
        }

        class C {
            public:
                ...
            private:
                friend class A;
        }
    private:
        ...
}

Whereas if it funcis a member function of A, then the following error does not occur:

class A {
    public:
        class B {
            public:
                ...
            private:
                friend class A;
        }

        C func() const {
            ...
        }

        class C {
            public:
                ...
            private:
                friend class A;
        }
    private:
        ...
}

How can I fix this so that the first work works?

I found a great example here .

+5
source share
1 answer

Define class C "above" class B or redirect it.

+8
source

All Articles