I'm not entirely sure what you're trying to achieve, but since each
Char_Type<T>
is a unique type, they can only be assigned to the same collection (in your case the
temp[]
array), if they're subclasses of the same base class (or an instance of that base class).
class some_base
{
};
template<class T> class Char_Type : public some_base
{
public:
T value;
Char_Type()
{
};
Char_Type(const T& v)
{
value = v;
};
};
int main(int argc, char* argv[])
{
some_base* a = new some_base[3];
a[0] = Char_Type<char>('c');
a[1] = Char_Type<int>(123);
a[2] = Char_Type<int>(123.23);
delete[] a;
return 0;
}
But I think such a setup would cancel what you're trying to do.