Original Post
Hey , I just want to clarify if what I presume is true. Given the following: I know that the delete operator actually deletes the object the pointer is pointing to , so what happens to the 3 other pointers pointing to the that object? Are they now pointing to NULL or to nothing at all? Now consider this example: A pointer in FooList1 points to the same object that a pointer in FooList2 points to. If I empty one of the containers and delete all of it's pointers , does this mean that all of the pointers in the other container will become invalid and 'dangerous' to use because they will point to nothing? Lastly , a pointer that points to nothing , it has it's own address and memory location. Does the OS clean up pointers like that so it wont be considered as a memory leak?
class Foo
{
/......./
};
int main()
{
Foo *p = new Foo();
Foo *p1 = p;
Foo *p2 = p;
Foo *p3 = p;
delete p;
}
// FooList1.h
vector<Foo*> FooList1;
// FooList2.h
vector<Foo*> FooList2;