This is called a forward declaration, which is essentially a promise to define this class later. Having a direct declaration allows you to declare pointers to HereIsMyClass without having to include a header file in it, but not its actual objects, since the size of the HereIsMyClass object is still unknown to the compiler.
class HereIsMyClass; class Foo { private: HereIsMyClass *pointer; // works HereIsMYClass object; // compiler error! };
In a direct declaration, the compiler does not say anything about class members, so you still need to include the full class definition (header file) whenever you use it, i.e. e. access to its members.
Dima
source share