O'Reilly logo

C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart by Brian Overland

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

11 The Fraction Class

Some people talk about object orientation as though it were easy: You wave the magic wand of C++ and your troubles disappear. But writing a useful class requires thought and planning. To be reusable—to offer so much that other programmers will make use of it—requires that you place serious functionality into the class.

But the good news is that once you develop, write, and test a class that truly meets your needs, you’ve created a strong addition to the C++ language. Alternatively, you can use classes and objects as a way to package code and data together.

Because the task of writing a real class is involved, I’m going to focus mainly on a single class over the next several chapters: the Fraction class, which (when done) ...

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