With static polymorphism, I believe you should approach the problem this way:
- - - - - - - - - - - - - #include <iostream>
class RadioButton { public: void Draw() const { std::cout<<"radio button"<<std::endl; } };
class TextButton { public: void Draw() const { std::cout<<"text button"<<std::endl; } };
template<typename T> void Draw(T const& t) { t.Draw(); }
int main() { RadioButton rb; Draw(rb); TextButton tb; Draw(tb); } - - - - - - - - - - - - -
You cannot have heterogenous collections of static polymorphic objects.
If you need a heterogenous collection of polymorphic objects, you need dynamic polymorphism. (And, if so, I recommend using interface classes ... classes consisting of nothing but pure virtual methods. I recommend interface classes as a rule-of-thumb.)
HTH, --Eljay