Author: nickf3nickf3 Date: May 1, 2007 10:52
On May 1, 1:05 pm, "Victor Bazarov" comAcast.net> wrote:
> Dave wrote:
>> A quick question:
>
>> vector test_vec;
>> T testT;
>> test_vec.push_back(&testT);
>
>> T * testT2p = new T;
>> test_vec.push_back(testT2p);
>
>> Now at the end do I need to explicitly delete the vector (test_vec).
>
> Only the elements that were explicitly 'new'ed.
>
>> How should I make sure that the memory allocation is ok?
>
> There is no other non-implementation-specific way except to keep
> some kind of flag to distinguish between the ones you got from 'new'
> and the others. ...
|