I want to return an iterator for a data type for a function and wondering if it will be destroyed when the function goes out of scope.
Are iterators created in free store the heap or on the stack.
I may be a little confused it is not necessary to destroy a pointer correct just the object it points to. So if you use new you must use delete to destroy the object though you use the pointer name. Is this why some suggest assigning the pointer to null after delete.
I am guessing scope rules apply normally to pointers (hence they are stored on the stack) but the objects pointed are still on the heap so you can loose the ability to delete the object if you do not return a refrence to the pointer correct.
If not how do you destroy the actual pointer.
Also I asked somtime ago if container.clear() calls the destructor for the objects within the container. Is this true when the container contains pointers.
The people at gamedev said you need to call delete for every object in a containor (vector) before using the clear function.