In a related question I asked about creating a generic container. Using polymorphic templates seems like the right way to go.
However, I can't for the life of me figure out how a destructor should be written. I want the owner of the memory allocated to be the containers even if the example constructor takes in an array of T
(along with its dimensions), allocated at some other point.
I would like to be able to do something like
MyContainer<float> blah();
...
delete blah;
and
MyContainer<ComplexObjectType*> complexBlah();
...
delete complexBlah;`
Can I do something like this? Can I do it without smart pointers?
Again, thanks for your input.