I wonder, if i have an instance of a class, and a private pointer to a queue or avector, when the instance is being destructed, does the STL will be detruct too or do I need to delete[] it?? Moreover, if I have a private pointer to queue/vector, containing pointers to some object instace, if all the instances to which the pointer points was destructed, what happend to the queue/vetor?
Asked
Active
Viewed 41 times
0
-
Do you hold the container by value or pointer? – StoryTeller - Unslander Monica Dec 03 '17 at 07:43
-
pointer :) @StoryTeller – Dec 03 '17 at 07:47
-
1Then nothing will happen automatically. It's no different to holding a `int` by pointer. And just like an `int`, it's pointelss to hold it by pointer. Those containers have value semantics for a reason. – StoryTeller - Unslander Monica Dec 03 '17 at 07:48
-
I can assure you that private has nothing to do with anything here. – juanchopanza Dec 03 '17 at 08:06
-
the private is really not the issue here, just a sample .. @juanchopanza – Dec 03 '17 at 08:24
-
Don’t use pointer for vector or queue. You have to `delete` whatever you `new` exactly once. – Dec 03 '17 at 09:25
-
thank friend ! @manni66 – Dec 04 '17 at 14:38