The string class—and most other library types—defines several companio dịch - The string class—and most other library types—defines several companio Việt làm thế nào để nói

The string class—and most other lib

The string class—and most other library types—defines several companion types.

These companion types make it possible to use the library types in a machine-
independent manner. The type size_type is one of these companion types. To use the

size_type defined by string, we use the scope operator to say that the name

size_type is defined in the string class.

Although we don’t know the precise type of string::size_type, we do know

that it is an unsigned type (§ 2.1.1, p. 32) big enough to hold the size of any

string. Any variable used to store the result from the string size operation

should be of type string::size_type.

Admittedly, it can be tedious to type string::size_type. Under the new

standard, we can ask the compiler to provide the appropriate type by using auto or

decltype (§ 2.5.2, p. 68):

Click here to view code image

auto len = line.size(); // len has type string::size_type

Because size returns an unsigned type, it is essential to remember that

expressions that mix signed and unsigned data can have surprising results (§ 2.1.2, p.

36). For example, if n is an int that holds a negative value, then s.size() < n will

almost surely evaluate as true. It yields true because the negative value in n will

convert to a large unsigned value.

Tip

You can avoid problems due to conversion between unsigned and int by

not using ints in expressions that use size().
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
The string class—and most other library types—defines several companion types.These companion types make it possible to use the library types in a machine-independent manner. The type size_type is one of these companion types. To use thesize_type defined by string, we use the scope operator to say that the namesize_type is defined in the string class.Although we don’t know the precise type of string::size_type, we do knowthat it is an unsigned type (§ 2.1.1, p. 32) big enough to hold the size of anystring. Any variable used to store the result from the string size operationshould be of type string::size_type.Admittedly, it can be tedious to type string::size_type. Under the newstandard, we can ask the compiler to provide the appropriate type by using auto ordecltype (§ 2.5.2, p. 68):Click here to view code imageauto len = line.size(); // len has type string::size_typeBecause size returns an unsigned type, it is essential to remember thatexpressions that mix signed and unsigned data can have surprising results (§ 2.1.2, p.36). For example, if n is an int that holds a negative value, then s.size() < n willalmost surely evaluate as true. It yields true because the negative value in n willconvert to a large unsigned value. TipYou can avoid problems due to conversion between unsigned and int bynot using ints in expressions that use size().
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Chuỗi đẳng cấp và hầu hết các thư viện khác loại có định nghĩa một số loại đồng. Những loại đồng làm cho nó có thể sử dụng những loại thư viện trong một tư thiết cách độc lập. Các loại size_type là một trong những loại đồng. Để sử dụng size_type xác định bởi chuỗi, chúng ta sử dụng toán tử để nói rằng tên size_type được định nghĩa trong lớp string. Mặc dù chúng ta không biết loại chính xác của chuỗi :: size_type, chúng tôi biết rằng đó là một loại không dấu (§ 2.1.1, p. 32) đủ lớn để giữ kích thước của bất kỳ chuỗi. Bất kỳ biến được sử dụng để lưu trữ các kết quả từ các hoạt động kích thước chuỗi nên là kiểu string :: size_type. Phải thừa nhận rằng, nó có thể mất đến gõ chuỗi :: size_type. Dưới sự mới tiêu chuẩn, chúng tôi có thể yêu cầu các trình biên dịch để cung cấp các loại thích hợp bằng cách sử dụng tự động hoặc decltype (. § 2.5.2, p 68): Bấm vào đây để xem hình ảnh mã auto len = line.size (); // Len có kiểu string :: size_type Bởi vì kích thước trả về một kiểu unsigned, nó là điều cần thiết để ghi nhớ rằng các biểu thức trộn ký và dữ liệu unsigned có thể có kết quả đáng ngạc nhiên (§ 2.1.2, p. 36). Ví dụ, nếu n là một int mà giữ một giá trị tiêu cực, sau đó s.size () <n sẽ gần như chắc chắn đánh giá là đúng sự thật. Nó mang đúng bởi vì các giá trị tiêu cực trong n sẽ chuyển đổi một giá trị unsigned lớn. Mẹo Bạn có thể tránh vấn đề do chuyển đổi giữa unsigned int và do không sử dụng ints trong các biểu thức sử dụng size ().








































đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2025 I Love Translation. All reserved.

E-mail: