Exercises

  1. 3.5 (Default Constructor) What’s a default constructor? How are an object’s data members initialized if a class has only a default constructor defined by the compiler?

  2. 3.6 (Data Members) Explain the purpose of a data member.

  3. 3.7 (Using a Class Without a using Directive) Explain how a program could use class string without inserting a using directive.

  4. 3.8 (Set and Get Functions) Explain why a class might provide a set function and a get function for a data member.

  5. 3.9 (Modified Account Class) Modify class Account (Fig. 3.8) to provide a member function called withdraw that withdraws money from an Account. Ensure that the withdrawal amount does not exceed the Account’s balance. If it does, the balance should be left unchanged ...

Get C++ How to Program, 10/e 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.