Hi,
I'm trying to do something like the following...
I would like fill a vector with objects that are of different type variations of the same template base class.
The code below of course does not work because the vector needs a template arg. How do you get around this? A wrapper class? If so, how?
Thanks!
Code:template <class T> class MyClassBase { public: MyClassBase() { } T myValue; }; class MyClassFloat : public MyClassBase<float> { MyClassFloat(float myInput) { myValue = myInput; } }; class MyClassInt : public MyClassBase<int> { MyClassInt(int myInput) { myValue = myInput; } }; int main (int argc, const char * argv[]) { vector<MyClassBase> myVec; myVec.push_back(MyClassFloat(1.0)); myVec.push_back(MyClassInt(1)); return 0; }