C ++ primer-string: size_type

Source: Internet
Author: User

The string type and many other library types define some ancillary types.
With these types, the use of database types can be unrelated to machines.
For example, string: size_type:
String. Size () returns a value of the size_type type. The return value cannot be assigned to an int variable.
We do not know the exact type of size_type, but we know it is an unsigned type. The value is much larger than the signed type.
To avoid overflow, the safest way to save the size of a string object is to use size_type.

On the other hand, when the following standard value is used to obtain characters in the string, such

String A = "test"

Char c = A [Index]

The size_type type is also recommended for index.

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.