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) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access