Two ways:
(1):
Wrap each header file in an #ifndef, like so:
myheader.h:
Code:
#ifndef _MYHEADER_H_
#define _MYHEADER_H_
//Contents here
#endif
//EOF
This should solve most problems, and you should always do this, no matter what the situation.
The second way, which is sometimes needed, is to prototype the class, function, or datatype being used. Like so:
Code:
int MyFunc(int); // Prototype
class B; //Prototype
class A
{
public:
bool MyBool;
B MyB;
};
class B //Declaration
{
public:
bool YetAnotherBool;
};
int main(int argc, char **argv) //Declaration
{
}
int MyFunc(int iI) //Declaration
{
//Do something
}
Hope that helps. By the way, if you have a multi-file project, you might want to read up on the "extern" keyword.