12 Constructors: If You Build It…
One of the themes in this book is that object orientation is a way to create a fundamental new data type. I’ll focus on that idea for several chapters.
But I haven’t yet come through on this promise—that you can make classes as convenient as standard data types. One of the most convenient features of types such as int, float, double, and so on is that you can initialize them as you declare them. (C++ is somewhat more liberal than C in this regard; you can initialize with any value, not just constants.)
You’re about to see how easy it is to support initialization for objects, as well. Welcome to the craft of C++ construction.
Introducing Constructors
The term constructor is just C++-speak for an initialization ...
Get C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.