Inheritance problem with **pointers

Hello!;)

i have been struggeling with a problem for a while.

im making my own "API" in HGE. I do have a inheritance of classes. The base class is called Component and is connected width the classes: Button, Label, textField and so on. I have a class called ComponentHandler. It handels the Components. for example addButton, addLabel and so on. I have declared dubbelpointers to the base class (the Component class) in the ComponentHandler as shown below.


//*******************************
class ComponentHandler
private:
Component** components;

//*******************************

I have a memberfunction called AddButton.
part of the code just to get it more clear:)

this->components[this->numberOfComponents] = new Button();


The thing is that i need to get access to the buttons memberfunctions. But because components i dubbelpointers to the base-class i cant get access to them. is there some way to get that? i tried casting bt didnt get it to work. Any help would be really appreciated:) i have been struggeling with this some time now:S

Possible method 1.

1
2
3
4
5
Button* pb = new Button();
//use pb to call the button functions

//now save the button pointer;
this->components[this->numberOfComponents] = pb;
Thanks for your fast reply!!;)

NumButton* temp = NULL;
temp = ((NumButton*)components[this->numberOfComponents]);


//here i do all i have to do with the numbutton pointer

this->components[this->numberOfComponents] = temp;


Thanks!!;) helped alot!!:)
Topic archived. No new replies allowed.