C + + prime:sizeof operators

Source: Internet
Author: User

The results of the sizeof operator are partially dependent on the type of action:

The result of a sizeof operation on a char or an expression of type char is 1;

Performs a sizeof operation on a reference type to obtain the size of the space occupied by the referenced object;

The size of the space occupied by the pointer itself is obtained by performing the sizeof operation on the pointer;

Performing the sizeof operation on the dereference pointer gets the size of the space occupied by the object pointed to by the pointer, and the pointer does not need to be valid;

Performing the sizeof operation on an array results in the size of the total space occupied by the arrays, equivalent to all elements of the array performing the sizeof operation once and summing the resulting result;

Performing a sizeof operation on a string object or a vector object returns only the size of the fixed part of the type, and does not calculate how much space the elements in the object occupy.

C + + prime:sizeof operators

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.