Reputation: 65
I am wondering if there is a way to have a vector of templated objects with different template types example
template<class T>
class object
{
public:
void function()
{
}
};
int main()
{
std::vector<object> v;
v.push_back(object<int>());
v.push_back(object<char>());
v.push_back(object<const char*>());
}
I get the following error "argument list for class template "object" is missing". I understand that I need to pass a type for the template, but is it possible to hold a collection of objects with varying template types? any help would be appreciated.
Upvotes: 0
Views: 631
Reputation: 533
Others can correct me if I am wrong but I think you have 3 options.
If you provide details of what you plan to store it would be easier to advise you.
Upvotes: 2