21.4 — STL algorithms overview

In addition to container classes and iterators, STL also provides a number of generic algorithms for working with the elements of the container classes. These allow you to do things like search, sort, insert, reorder, remove, and copy elements of the container class. Note that algorithms are implemented as functions …

21.3 — STL iterators overview

An Iterator is an object that can traverse (iterate over) a container class without the user having to know how the container is implemented. With many classes (particularly lists and the associative classes), iterators are the primary way elements of these classes are accessed. An iterator is best visualized as …

21.2 — STL containers overview

By far the most commonly used functionality of the STL library are the STL container classes. If you need a quick refresher on container classes, check out lesson . The STL contains many different container classes that can be used in different situations. Generally speaking, the container classes fall into …

21.1 — The Standard Library

Congratulations! You made it all the way through the primary portion of the tutorial! In the preceding lessons, we covered many of the principal C++ language features (including a few from the C++11/14/17 extension to the language). So the obvious question is, “what next?”. One thing you’ve probably noticed is …

22.7 — std::string inserting

Inserting Inserting characters into an existing string can be done via the insert() function. Here’s a crazy version of insert() that allows you to insert a substring into a string at an arbitrary index: There is a flavor of insert() that inserts the first portion of a C-style string: There’s …

22.6 — std::string appending

Appending Appending strings to the end of an existing string is easy using either operator+=, append(), or push_back(). There’s also a flavor of append() that can append a substring: Operator+= and append() also have versions that work on C-style strings: There is an additional flavor of append() that works on …

22.4 — std::string character access and conversion to C-style arrays

Character access There are two almost identical ways to access characters in a string. The easier to use and faster version is the overloaded operator[]: There is also a non-operator version. This version is slower since it uses exceptions to check if the nIndex is valid. If you are not …