vecPtr
does not need to be deleted, because it is not a pointer. This might be different for the pointers in vecPtr
and depends on who has the ownership for those pointers.
Yes, testPtr
must be deleted, where it is available. Anything else won't even compile. If you point testPtr
to a member and delete that, you will likely see a double free or corruption error when the member would be deleted on the destructor.
In general where something must be deleted is up to the implementation. The only thing that you need to look out for is that every new gets exactly one delete from somewhere in any code path. Usually constructors/destructor are therefore a good place.