Is there a way to use class wtihout header file?

This is a discussion on Is there a way to use class wtihout header file? within the C++ Programming forums, part of the General Programming Boards category; Hi
For example i have .h and .cpp file that define my class like that:
Code:
//a.h
class CExample {
...

I think the confusion here is about "what can be made extern and what cant".

Types MUST be known by the compiler when their content is being used. Since a declaration of a class (or struct) in C++ involves calling the constructor for that class (and the constructor(s) of it's parent class(es)), the compiler must know what those constructors are and where these constructors are, and to know that, the compiler must know the entire content of the type, meaning that you have to include the header-file that contains that type (or some other way give the compiler the contents of the type - if you want to repeat the declaration of the class multiple times, that's fine too - but has the drawback of needing to be modified in several places if there's ever a need to modify the class).

A variable (instance) can be declared extern, such as "extern CExample b;" - however, that tells the compiler that there is a declaration of this variable somewhere else. You can't initialize (give it values) here, that must be done at the "main declaration", which also where the constructor is being called.

If you ever need to use the CONTENT of b as declared above, it will still need to be known to the compiler, so there's really no way around having it either included in the source code, or from a header-file.