Based on my experience there is two ways to instantiate an object.
Method 1:
Car* car1 = new Car();
Method 2:
Car car1;
So, my question is what really is the difference in the two methods. Does
one get stored on the stack while the other gets stored on the heap? Is one
better than the other? How is one to reference the difference between the
two, that is is the firt method called instantiation by ? while the second
one is called instantiation by ?
Any advice is greatly appreciated,
John
Method 1:
Car* car1 = new Car();
Method 2:
Car car1;
So, my question is what really is the difference in the two methods. Does
one get stored on the stack while the other gets stored on the heap? Is one
better than the other? How is one to reference the difference between the
two, that is is the firt method called instantiation by ? while the second
one is called instantiation by ?
Any advice is greatly appreciated,
John
Comment