Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Point p1 = Point(0,0);
- Point* p1 = new Point(0, 0);
- void foo()
- {
- Point p = Point(0,0);
- } // p is now destroyed.
- for (...)
- {
- Point p = Point(0,0);
- } // p is destroyed after each loop
- class Foo
- {
- Point p;
- }; // p will be automatically destroyed when foo is.
- void foo(int size)
- {
- Point* pointArray = new Point[size];
- ...
- delete [] pointArray;
- }
- void SomeFunc()
- {
- Point p1 = Point(0,0);
- } // p1 is automatically freed
- void SomeFunc2()
- {
- Point *p1 = new Point(0,0);
- delete p1; // p1 is leaked unless it gets deleted
- }
- Point p1 = Point(0,0); //This is if you want to be safe and don't want to keep the memory outside this function.
- Point* p2 = new Point(0, 0); //This must be freed manually. with...
- delete p2;
Add Comment
Please, Sign In to add comment