//base class
class InterfaceItem
{
public:
//iterates through m_SubItems vector looking for an item with that name and
//returns it
InterfaceItem* GetSubItem(string Name);
private:
vector<InterfaceItem*> m_SubItems;
}
//one of the classes that derive from InterfaceItem
class Window : public InterfaceItem
{
//other functions
}
So if I do something like
1 2
Window ThisWindow; //pretend it is already initialized and has sub-items
ThisWindow.GetSubItems();
it will return an object of type InterfaceItem*, so I am not able to access any of the Window specific functions unless I do something like
I've tried this and I got some WEIRD errors. Files that pretty had nothing to do with this started saying classes that were clearly #included didn't exist and some other weird stuff
In the end I managed to use template functions. I found out the reason I was getting those absurdly strange errors was because I was using this syntax <class Type*>, where the "*" makes no sense. I just removed that part and it compiled correctly, after I changed the call I wanted to "(...)->template GetSub<Window>("name to look for").(rest of the code)".