stackVar^heap object

In a C++ program, there is exactly
* one heap
* one stack — locals (ie auto variables) and static locals.
* one global space — globalVar is defined outside all functions.

An object (float, int, user-defined…) lives in one of the 3

In terms of cleanup, heap objects need delete (never automatically deallocated); global var lives forever; auto var has automatic cleanup. static locals live forever. [[ absolute c++]]

You can reasonably seat your ptr at
* globals
* static locals
* autos in main()
* heap objects

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s