O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

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

A.3. IOStream Examples

This section presents several longer examples of the IOStream library. In “Overloading Streams” on page 324, we demonstrate overloading operator<<() and operator>>() for String objects. Let's do this for class Hue, a structure that stores and manipulates composite objects.

Hue

For simplicity, we've made Hue a structure with no constructor and all public data members. Hue objects consists of a character array, an integer, and a float. The main behavior we've given Hue objects is stream input and output by overloading operator<<() and operator>>(). Here is header file Hue.h.

Listing A.5. Hue structure definition
 #ifndef HUEH #define HUEH // Hue.h - Hue data type #include <iostream.h> #include <iomanip.h> struct Hue { char ...

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