This may seem weird but I have a problem in one of my programs where I have a class A which needs a variable of class B inside it, and the class B needs a pointer to class A inside it, so that I can determine which class is attached to what….
I get errors because in class A it says that the class B is not defined yet, and in class B it says class A isn’t defined yet…
Both of my header files which contain the separate classes include each other and I have tried to forward declare my classes e.g. class A; class B; but I get compiler errors such as:
error C2079: 'CFrame::menu' uses undefined class 'CMenu'
I need a pointer to class A in class B because I want to pass it to another class later on.
You need to declare
Abefore you defineB:This kind of declaration is often referred to as a forward declaration.