I create a GUI class for C ++ and deal with pointers a lot. Call example:
mainGui.activeWindow->activeWidget->init();
My problem is that I want to use the activeWidget pointer for another type. activeWidget is of type GUI_BASE. Derived from BASE, I have other classes such as GUI_BUTTON and GUI_TEXTBOX. I want to highlight the activeWidget pointer from GUI_BASE to GUI_TEXTBOX. I assume it will look something like this:
(GUI_TEXTBOX*)(mainGui.activeWindow->activeWidget)->function();
This does not work because the compiler still considers the pointer to be of type GUI_BASE. However, the following bit of code works:
GUI_TEXTBOX *textbox_pointer; textbox_pointer = (GUI_TEXTBOX*)mainGui.activeWindow->activeWidget; textbox_pointer->function();
I hope my problem here is just a syntax problem. Thanks for the help:)
source share