I have a little problem that I was hoping somebody here could help me with. I have two classes, CMenu and CMenuItem, which are defined in their own header files "Menu.h" and "MenuItem.h" respectively. Now, the problem is that they both need to reference each other, as an instance of CMenu needs to have an array of CMenuItems and each CMenuItem needs to have an instance of CMenu. How do I setup my header file(s) so that I do not get errors because one doesn't know about the other????
I guess I could use a void pointer (void*) but that would seem to defeat the purpose. I'm sure there is a logical way to do this as I am sure there is no way I am the first person who has needed to do something like this...Code:// contents of file Menu.h #pragma once #include "MenuItem.h" class CMenu { private: CMenuItem* m_lpItems; int m_nItemCount; public: CMenu(); virtual ~CMenu(); }; //------------------------------------- // contents of file MenuItem.h #pragma once #include "Menu.h" class CMenuItem { private: CMenu* m_lpSubMenu; public: CMenuItem(); virtual ~CMenuItem(); }
Any ideas??
Thanks,
Rippin




Reply With Quote