*Stack allocation
Image myImage;
myImage.SetAllPixels(ClearColor);
*Heap allocation
Image *imagePtr;
imagePtr = new Image();
imagePtr->SetAllPixels(ClearColor);
...
delete imagePtr;
Stack allocation: Constructor and destructor called automatically when the function is entered and exited.
Heap allocation: Constructor and destructor must be called explicitly.
Image myImage;
myImage.SetAllPixels(ClearColor);
*Heap allocation
Image *imagePtr;
imagePtr = new Image();
imagePtr->SetAllPixels(ClearColor);
...
delete imagePtr;
Stack allocation: Constructor and destructor called automatically when the function is entered and exited.
Heap allocation: Constructor and destructor must be called explicitly.
No comments:
Post a Comment