How to delete memory used in constructor

So I have a constructor with the following statement:

queue<T> *newQueue = new queue<T>;

How can I deallocate this memory in the constructor?

delete newQueue; of course. What's the problem?
Last edited on
Why not create the queue as queue<T> newQueue;? That way it will automatically be deallocated when the constructor ends.
Or, if it really must be a pointer to a queue, you could use a smart pointer (std::auto_ptr I think, with some other options in boost if you have that available)
Topic archived. No new replies allowed.