mardi 28 avril 2020

Is it possible to create a vector of a template class and call its functions?

I created a template class with some methods that use as parameter template type like this:

template <class T>
class vector{
... 
void new(const T&new_value)
...
}

I want to use it inside another class but since it's not allowed to declare it like this:

class matrix{
vector _ptr_to_vect;
}

I created a base class BaseVector.

But in BaseVector I cannot define a virtual function like new(const T&new_value) to override it (because I don't want to use template again). Since I cannot define it then is not possible to call it like:

BaseVector _ptr_to_vect;
BaseVector[0].new("new value")

Aucun commentaire:

Enregistrer un commentaire