Hi I have the following problem. I have two classes and two header files. However, One class needs to use the other, and vice-versa. Now when I compile, because a has already been defined, when the preprocessor comes to class b, it will open up class a's header file find that a has already been defined (because the preprocessor did class a first), and therefore a's class definition will not get inserted into class b's header file. Then the compiler will throw an error will say a is undefined within class b. Which is correct. How do I get around this problem? If I got rid of the preprocessor commands I would probably get a class redefinition error... Code below is only illustration!
Any help would be appreciated. Additionally, if some of my thinking is slightly off regarding the actions of the preprocessor, please dont have a go.Code:#ifndef a #define a #include "b.h" Class a { b *tmp; } #endif #ifndef b #define b #include "a.h" Class b { a *tmp; } #endif