Nested classes can now be forward declared just like other
classes:
As an aside, this provides an interesting contrast with C where the following is already legal:
class Outer
{
class Inner;
public:
Inner* getCookie();
private:
class Inner
{
// ...
};
};
They can also be declared inside the outer class and then defined outside the class:
class Outer
{
class Inner;
public:
Inner* getCookie();
};
class Outer::Inner
{
// ...
};
As an aside, this provides an interesting contrast with C where the following is already legal:
struct Outer
{
struct Inner
{
};
};
Inner x; // C++ requires Outer::Inner!
Some C++ compilers still allow this lapse of scope-awareness. This is probably more of an issue for vendors that produce a combined C/C++ compiler - as most of the PC vendors do - and it is certainly an issue for portability from legacy C code .