One of the key design goals for C++ was that you should be able to define brand-new types that look and act similar to the built-in types. Do you need tri-state logic? Write your own tribool type. Need arbitrary-precision arithmetic? Write your own bigint type. Even better, let someone else write it, and you use bigint in the same manner as ordinary int. This Exploration introduces some of the language features that let you define custom types. Subsequent Explorations delve deeper into these topics.
Defining a New Type
Let’s consider a scenario in which you want to define a type, rational, to represent ...