Chapter 11. Strings

This chapter presents the string types of the C++ standard library. It describes the basic template class basic_string<> and its standard specializations string and wstring.

Strings can be a source of confusion. This is because it is not clear what is meant by the term string. Does it mean an ordinary character array of type char* (with or without the const qualifier), or an instance of class string, or is it a general name for objects that are kind of strings? In this chapter I use the term string for objects of one of the string types in the C++ standard library (whether it is string or wstring). For "ordinary strings" of type char* or const char*, I use the term C-string.

Note that the type of string literals (such as "hello" ...

Get The C++ Standard Library: A Tutorial and Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.