I have the following class:
template <typename T>
class A
{
public:
void method(const char *buffer);
// the template T is used inside this method for a local variable
};
Now I need an array of instances of this class with different templates like:
std::vector<A*> array;
array.push_back(new A<uint32_t>);
array.push_back(new A<int32_t>);
But std::vector<A*> array; wont work, because I apparently need to specify a Template, but i can’t so that because I store different types in this array. Is there some kind of generic type or an other solution?
You need a base class:
then use it like