Exercises

  1. 9.3 (Scope Resolution Operator) What’s the purpose of the scope resolution operator?

  2. 9.4 (Enhancing Class Time) Provide a constructor that’s capable of using the current time from the time and localtime functions—declared in the C++ Standard Library header <ctime>—to initialize an object of the Time class. For descriptions of C++ Standard Library headers, classes and functions, see http://cppreference.com.

  3. 9.5 (Complex Class) Create a class called Complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form

    
    realPart + imaginaryPart * i
    

    where i is

    1

    Use double variables to represent the private data of the class. Provide a constructor that enables an object ...

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.