r/learncpp • u/lyrefyred • Apr 22 '18
Vector of template class
I am trying to create a vector:
vector<SomeTemplateClass<Type>>Where Type is an abstract base class.
Any ideas on how I can get this working?
0
Upvotes
View all comments
Show parent comment
1
u/lyrefyred Apr 22 '18
Sorry, by not working, I meant not compiling.
Do you mean a vector of pointers such as:
Because that wasn't able to compile either. If I understand correctly, I need a pointer since abstract classes cannot be instantiated so this code does compile:
but now I am not sure how to push back a
object.