-
Template confusion
Heya,
How, or indeed can, I create a class containing an array of templated classes with different types?
Umm, like maybe this-
Code:
template <class T> item{
public:
T data;
};
class container{
public:
void add(<class T>,T);
item*<> items;
};
Where I could add to the items array with different types for each element, can I do this at all?
-
>can I do this at all?
Not in a practical way. You'll want to redesign your code so that you can take advantage of polymorphism.
-
Ahh, perfect. I've rewritten it using polymorphism, and it's a lot more suited to my purpose anyway..
Thanks a lot! :)