Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Bjarne Stroustrup once wrote an article with the curious title, “Sixteen Ways to Stack a Cat” [27]. It turns out that there are almost as many ways to implement strings. As experienced and sophisticated software engineers, of course, we’re supposed to pooh-pooh “implementation details,” but if Einstein is right and God is in the details, reality requires that we sometimes get religion. Even when the details don’t matter, having some idea about them puts us in a position to be sure they don’t matter.
For example, what is the size of a string object? In other words, what value does sizeof(string) return? This could be an important question if you’re keeping a close eye on memory consumption, and you’re thinking of replacing a raw char* pointer with a string object.