I have a few header files (one has type definition, the others contain classes). The problem is that I want to be able to include a basic header that will have all my definitions, classes, etc with one line (the include). For example, something like this;
cpp
#include "myheader.h"
int main()
{
MyClass c;
//... some code here
}
cpp
#ifndef _MYHEADER_
#define _MYHEADER_
typedef std::vector<sometype> MyType;
//this is the problem
#include "myclassdef.h"
#endif //_MYHEADER_
cpp
#ifndef _MYCLASSDEF_
#define _MYCLASSDEF_
//this is the problem
#include "myheader.h"
//my class requires one of the typedefs
class MyClass
{
MyType myvar; // <-- this is what uses the typedef
//... some definitions
}
#endif
But if I need the typedef in "myclassdef.h" then it makes me include "myheader.h" within "myclassdef.h". Here's where the problem starts.. anything in "myheader.h" gets redeclared (obviously).
So how do do my definitions (specifically the typedef) and be able to include my classes within the header. Can extern be used on typedefs?
Thanks for any advice.