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

14. Dynamic Memory and the String Class

If you have a C++ compiler created in the past 5 or 10 years, you almost certainly have support for the Standard Template Library (STL), and that includes support for the automatic new string class described in Chapter 7—in addition to old-fashioned C-strings (arrays of char).

But in this chapter, we’re going to write our own version of the string class, calling it String. Why go to this trouble? Because the String class, even though it’s already provided for you, provides a perfect demonstration of many things you need to consider when writing your own classes, including the use of the new, delete, and this keywords.

And if by some chance you don’t have a compiler that supports STL, you can always use ...

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