Allocation of C + + object memory

Source: Internet
Author: User

1 about C + + objects

As long as it is defined by class or struct, it is an object, regardless of the method. However, in general, objects with no methods are defined with the struct keyword.

2 define an object without the New keyword

To see where such an object is in memory, look at the context in which it is located.

If it is in a function, then the memory of the object is on the stack of the function, whose life cycle is the function's life cycle.

If defined as a member variable of another class, the object's position depends on where the class containing it is located, where the class containing it is, and where it is.

3 objects defined with the New keyword

The memory of the object is above the heap.

Allocation of C + + object memory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.