Example:
// can't forward declare with class Foo::Bar // actual class class Foo { public: class Bar // or enum Bar { } };
I agree that this is prohibited by current C ++ standards, but I couldnโt come up with a good reason not to allow this, especially with C ++ 0x, now we can forward declare enumerations. I would suggest that the argument against this would be that if we declare a nested class that turns out to be private, it will not be allowed. But that would not be too different to say that you need to declare a class in the namespace, and then declare it a nested class of the outer class. The compiler would simply give an error (perhaps the error message along the line of the previous declaration does not match this declaration).
So why is this really not allowed?
In other words (James McNellis), "why is the class Foo :: Bar, without providing a definition for Foo or Bar not allowed?"
** Given that the C ++ standards committee recognized the advantage of using forward declarations to reduce dependencies and compilation time by introducing direct declaration of enumerations in C ++ 0x, this is certainly part of the same, isnโt it?
Zach saw
source share