I don't know how to resolve a problem with templates and inheritance.
In my code there is a templated class which looks more or less like:
template<typename T>
class Derived : public Base{
T value;
public:
Derived(T arg) { value=arg; };
T getValue() { return value;};
};
class Base{
};
The only purpose of my Base class is to group an array of objects of the Derived class. The parameter T is generally double, float or complex, although int and structs might also become useful. (There should be several more similar derived classes with a few additional functions, later.)
I can create such a group
Base** M = new Base*[numElements];
and assign elements of the derived class to them, e.g.:
M[54] = new Derived<double>(100.);
But how can I find out that the 55th element has value 100 later? I would need something like
virtual T getValue() = 0;
but T is a typename of the derived class and may be different for any two elements of this array.