I'm new to c++.
I've got a Rectangle class. When I create a Rectangle object like this:
Rectangle R1(10,10,90,20); - Does R1 sit on the heap or stack?
- If I were to create it using the
newoperator, would only then it be on the heap?
(In general what would be the correct way to create an object in c++?)
To my understanding, if I create it without new the object sits on the stack and does not need to be deleted at the end of its life time. And if do create it with new
Rectangle* R = new Rectangle(1,1,1,1); it will be placed on the heap and would need to be de-allocated using delete.