Answer the question
In order to leave comments, you need to log in
When to use pointers to objects when declaring in C++?
I'm starting to learn C++ programming. Tell me, please, when to use : when declaring an object Object obj();
,
and when Object obj = new Object();
?
Answer the question
In order to leave comments, you need to log in
1. A method is a variable created on the stack.
2. This is a variable created in dynamic memory. Unless, of course, you or "your friend" did nothing with the new operator.
Heap memory is much larger than the stack area
Only all the same Object* obj = new, as it seems to me.
Using new allows you to create entities while the program is running.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question