Usually in C ++ you can only refer to announcements that were previously made in the translation block. However, in a class definition, the definition of member functions is allowed to refer to declarations made later in the class. Basically, the compiler restructures your definitions in the class so that they work as if they were written right after the class.
But this only applies to function definitions. Declaring this function (including parameter types) is not allowed. They can only link to ads that have already been made in file order.
So you can do this:
class Test { public: void Func(int x) {Inner foo;} private: class Inner {}; };
But not this:
class Test { public: void Func(Inner x) {} private: class Inner {}; };
Nicol bolas
source share