E
Erik Friis
Hi, I'm trying to create a class template like the following:
template <class Type>
class MyVector
{
MyVector();
~MyVector();
unsigned int MyCount;
Type* MyData;
}
where the destructor is defined like:
template <class Type>
MyVector<Type>::~MyVector()
{
delete [] MyData;
}
The problem is that when Type is something like a pointer to an object
then the destructor needs to delete each of those pointers before
deleting MyData, right? But if Type is an integral type such as
"unsigned int" then I don't need (or want) to do this....
So I thought that I might be able to use a specialization, but it
seems that there are too many cases to cover, no? Am I missing
something? Thanks for any direction!
template <class Type>
class MyVector
{
MyVector();
~MyVector();
unsigned int MyCount;
Type* MyData;
}
where the destructor is defined like:
template <class Type>
MyVector<Type>::~MyVector()
{
delete [] MyData;
}
The problem is that when Type is something like a pointer to an object
then the destructor needs to delete each of those pointers before
deleting MyData, right? But if Type is an integral type such as
"unsigned int" then I don't need (or want) to do this....
So I thought that I might be able to use a specialization, but it
seems that there are too many cases to cover, no? Am I missing
something? Thanks for any direction!