I'm still new to template classes. But I have a parent class and then a template child class.
namespace Foo::Bar {
class BaseClass {
// No declarations
};
template<typename ChildClassType>
class ChildClass : public BaseClass {
public:
/// Public declarations
private:
// Private Members
};
}
Edit: Including further information about the ChildClassType So I have several structs that will use this template class.
struct foofoo {
// Declarations
}
struct barbar {
// Declarations
}
I want to be able to have a vector of multiple Child classes of each type so I used
std::vector<std::unique_ptr<BaseClass>> allChildTypeVector;
std::unique_ptr<ChildClass<foofoo>> childPtr;
allChildTypeVectors.push_back(childPtr);
Which is recommended by several other answers on here. But I am getting.
no instance of overloaded function "std::vector<_Tp, _Alloc>::push_back ....." matches the argument list
This same error is given if I do allChildTypeVectors.push_back(new ChildClass<ChildClassType>);
I know something is going wrong with my types but I can't seem to figure it out.