7. Introducing Objects

Programming with objects is at the heart of C++ and gives it advantages over C and many other languages. In case you are apprehensive about this novel way to approach your programs, it should be made clear that objects are just a new data type, with nearly unlimited potential. You start by defining a class, a formal model of what something should do, and then you can create an instance of that class, which is the object itself. This is somewhat like how structures work (see Chapter 6, “Complex Data Types”) but more potent. For starters, an object can have within it both variables and functions, whereas structures are typically only made up of other variables.

The first thing you’ll need to know is how to write a simple ...

Get C++ Programming: Visual QuickStart Guide 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.