Object instantiation of memory allocation

Source: Internet
Author: User

1. Does the member function occupy storage space?

member functions do not occupy the storage space, only when called, go to the function entry address, call the Change function in return,
member functions are the same as normal functions

The dynamic memory allocation caused by the instantiation of an object only includes the space required for non-static member variables and virtual table pointers (if there are virtual functions)

member functions are placed in the code area and shared by multiple objects.

From a compilation perspective, member functions are no different from normal functions.
Only the parameters are modified by the C + + compiler, and the first argument is always this

2. A member function in a class is a function in a shared code snippet and does not occupy memory space;

3. The member functions defined in the class default to inline (inline), which are expanded at the call, so multiple copies of the function may exist in a program (except for functions declared outside the class in the Class), refer to C++primer

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.