






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of the string type in c++, explaining that it is a typedef of the template class basic_string<char>. It covers the creation of string objects, accessing string characters, and the use of string utilities such as length(), substr(), and swap(). The document also discusses string operators and their overloading, as well as the difference between length and capacity of a string.
Typology: Study notes
1 / 11
This page cannot be seen from the preview
Don't miss anything!







The string class has overloaded the ==, !=, <, >, >=, <= operators to operate onthe value of the strings instead of the reference of the string (as in C) 1 string s1("hello"); 2 string s
"world"; 3 string s3, s4; 4 5 s
s
s2; 6
appends the substring from s from index
to the number 7
of characters specified by the third parameter 8
the third parameter is not an index, but a length 9 s4.append(s3,
if (s
s4)
cout
s
s
endl; 13
cout
"s
s
endl; 16 cout
"s
s
endl; 17 cout
"s
s
endl; 18 cout
"s
s
endl;
The size or length of a string is the number of characters currently stored in the string - The capacity of a string is the number of characters that can be stored in the string withouthaving to allocate more memory - The max_size of a string is the maximum number of characters allowed in a string