MFC Programmer's SourceBook : Thinking in C++
Bruce Eckel's Thinking in C++, 2nd Ed Contents | Prev | Next

Exercises

  1. Create a simple class with an overloaded operator++. Try calling this operator in both pre- and postfix form and see what kind of compiler warning you get.
  2. Create a class that contains a single private char. Overload the iostream operators << and >> (as in Iosop.cpp) and test them. You can test them with fstreams, strstreams, and stdiostreams ( cin and cout).
  3. Write a Number class with overloaded operators for +, –, *, / , and assignment. Choose the return values for these functions so that expressions can be chained together, and for efficiency. Write an automatic type conversion operator int( ) .
  4. Combine the classes in Unary.cpp and Binary.cpp.
  5. Fix Fanout.cpp by creating an explicit function to call to perform the type conversion, instead of one of the automatic conversion operators.

Contents | Prev | Next


Go to CodeGuru.com
Contact: webmaster@codeguru.com
© Copyright 1997-1999 CodeGuru