O'Reilly logo

C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Second Edition by Brian Overland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

H. STL Classes and Objects

Although the Standard Template Library (STL) supports many useful templates, this appendix summarizes the use of just three (the ones used in this book):

• The string class

• The list template

• The stack template

The STL String Class

The features in this section require including <string>.

STL string objects are declared simply as string—or std::string if the std namespace is not being used. The simple string class actually instantiates the template class basic_string for type char, so the functions listed here are also supported by basic_string classes:

#include <string>basic_string<char>     s1;    // Equivalent to stringbasic_string<wchar_t>  s2 = L"Hello";  // Wide stringwcout << s2;

Once declared, string objects ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required