Conclusion

We've covered a lot of material about how a real, generally useful class such as string works in this chapter. In the next chapter, we'll continue with the saga of the string class, finishing up the additional functionality needed to turn it into a full-fledged concrete data type. We'll put this new functionality to the test in a modified version of the sorting algorithm from the early chapters that sorts strings rather than numeric values.

Answers to Exercises

  1. The output of the compiler should look something like this:

    strex1.cc: In function 'int main()':
    strex1.cc:21: member 'm_Length' is a private member of class 'string'
    

    This one is simple; since m_Length is a private member variable of string, a nonmember function such as main ...

Get Learning to Program in C++ 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.