No, it's not possible. And why whould you do that ? What is the cost of writing #include ?
To be more precise, how would your file be aware of you class definition if you don't tell it where to find it ?
Edit : @Gonmator One should not do it, it's bad. Having your class definition in the cpp file is horrible. The only moment one can do it is when the class is only used by this file. Then it should be static
Edit2: Well, i can't figure out how to put code in comment. Se, i meant to say :
#ifndef __YOURFILENAME_H__
#define __YOURFILENAME_H__
class myclass{}
#endif
It look like you are having a problem like this :
//classA.hh
class A{
B instanceofB;
}
//classB.hh
class B{
A instanceofA;
}
Doing this make some problems. Compiler says "Error : Use of incomplete blahblah.."
All you have to do is to add the class name on the top of your class definitions, like this :
//classA.hh
class B;
class A{
B instanceofb;
}
//classB.hh
class A;
class B{
A instanceofA;
}
Edit3: Look like i didn't understand the problem. But my answer can still be right afterall.