The rational type is an example of a class. Now that you’ve seen a concrete example of writing your own class, it’s time to understand the general rules that govern all classes. This Exploration and the next four lay the foundation for this important aspect of C++ programming.
Anatomy of a Class
A class has a name and members—data members, member functions, and even member typedefs and nested classes. You start a class definition with the struct keyword. (You might wonder why you would not start a class definition with the class keyword. Please be patient; all will become clear in Exploration 35.) Use curly braces ...