I have a question about deleting an object and pointers to them. First test:
a test;
a* test_ptr;
test_ptr = &test;
test.aPrint();
test_ptr->aPrint();
delete(test_ptr);
test.aPrint();
I've added printout in the constructor, destructor and function aPrint prints the text "aPrint" (ob).
constructor
aPrint
aPrint
destructor
aPrint
destructor
How can I get a call to the destructor twice? And how can I still use object test after deletion?
-----edit-----
So if I use new instead. Then I have to use delete or else I got leakage.
a* test_ptr;
test_ptr = new a;
test_ptr->aPrint();
delete(test_ptr);
Is this because this example uses the heap were the first example uses the stack?