Appendix F. THE string TEMPLATE CLASS

The string class is based on a template definition:

template<class charT, class traits = char_traits<charT>,
                 class Allocator = allocator<charT> >
class basic_string {...};

Here charT represents the type stored in the string. The traits parameter represents a class that defines necessary properties a type must possess to be represented as a string. For example, it should have a length() method that returns the length of a string represented as an array of type charT. The end of such an array is indicated by the value charT(0), the generalization of the null character. (The expression charT(0) is a type cast of 0 to type charT. It could be just a 0, as it is for type char, or, more generally, it could be ...

Get C++ Primer Plus, Fourth 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.