Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Object obj;
on the stack and the destructor will be called automatically when you exit the scope Object *obj = new Object;
on the "heap" and you will have to delete the object yourself
1. Memory. In the first case, the memory for the object will be allocated on the stack, in the second - on the heap.
2. Life time. In the first case, the object exists until the scope is exited, in the second case, until delete obj is called;
The first is created on the stack, the second is allocated memory in the heap.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question