December 2013
Beginner
656 pages
16h 42m
English
EXPLORATION 29
![]()
Custom Types
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. 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 rational numbers (fractions). A rational number has a numerator and a denominator, both integers. Ideally, ...
Read now
Unlock full access