11. Introducing Classes: The Fraction Class

It’s time to turn toward a new vista: the world of classes and objects. Up until now, you’ve read about features that are either already in the old C language or represent small refinements to that language.

The major feature of C++ is that it adds this new capability—classes—to the C language. (There’s also another big feature called templates we’ll get to in Chapter 16.) And to understand what classes are all about, we’ll develop a class that’s particularly useful and not too difficult to write: the Fraction class.

Object Orientation: Quasi-Intelligent Data Types

Before embarking on the journey of creating a Fraction class, let me say a few words as to why the journey is necessary. In other words, ...

Get C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.