3.2. Library string Type

Image

A string is a variable-length sequence of characters. To use the string type, we must include the string header. Because it is part of the library, string is defined in the std namespace. Our examples assume the following code:

#include <string>using std::string;

This section describes the most common string operations; § 9.5 (p. 360) will cover additional operations.

Image Note

In addition to specifying the operations that the library types provide, the standard also imposes efficiency requirements on implementors. As a ...

Get C++ Primer, Fifth Edition 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.