O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

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

Classes Versus Instances

A class and an object of a class are not the same thing, any more than blueprints and buildings are the same. A class describes the objects that can be created from it.

You create an object by creating an instance of a class—that is, by defining a variable of the type of the class. This is called instantiation.

The member variables of an object come into existence when the object is instantiated and are automatically destroyed when the object is destroyed.

Objects can be instantiated on the stack or from the heap, like any other variables. An object is destroyed when the program terminates, when it is deleted, or when its variable goes out of scope.

Declaring a Class

You can see that a class declaration looks just like ...

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