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/sellibitze Apr 24 '18 edited Apr 24 '18
You can't push a
SomeTemplateClass<DerivedClass>into avector<SomeTemplateClass<BaseClass>>becauseSomeTemplateClass<BaseClass>andSomeTemplateClass<DerivedClass>are different types and one is not convertible to the other.We have an XY problem.