I have class:
------------
class Component {
void setEnabled(bool state);
}
------------
I want "setEnabled " don't be virtual (there are many member functions. not virtual for efficient).
If a derived class "Button" does polymorhism in "setEnabled " then in this function:
------------
void func(Component &a) {
a.setEnabled(tr ue);
}
------------
will not be called "Button.setEnab led" but "Component.setE nabled" (because "setEnabled " is not virtual)
So, Because I create a library and I want to be far from these quiet errors
I ask:
Is there a trick to avoid polymorphism in this member function???
Thanks!
------------
class Component {
void setEnabled(bool state);
}
------------
I want "setEnabled " don't be virtual (there are many member functions. not virtual for efficient).
If a derived class "Button" does polymorhism in "setEnabled " then in this function:
------------
void func(Component &a) {
a.setEnabled(tr ue);
}
------------
will not be called "Button.setEnab led" but "Component.setE nabled" (because "setEnabled " is not virtual)
So, Because I create a library and I want to be far from these quiet errors
I ask:
Is there a trick to avoid polymorphism in this member function???
Thanks!
Comment