O'Reilly logo

C++ for the Impatient by Brian Overland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Classes and Objects

One of the central features of C++ is that of classes, the single most important ability that C++ adds to C. There are many ways to think of a class. One of the best ways is this: A class is a user-defined type. Once you declare it, you can use it just as you would int, char, or double.

By declaring a class, you create a fundamental new data type, extending C++ itself. You can, if you choose, define how the type responds to operators (such as +, -, or <). You can also provide services in the form of member functions, effectively creating intelligent data types. An object “knows” how to respond to function calls and retains that knowledge even when it is accessed through a pointer of a more general type. (This is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required