O'Reilly logo

Object-Oriented Programming with C++ by A.K. Sharma

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

6

CONSTRUCTORS AND DESTRUCTORS

6.1 CONSTRUCTORS

We know that a class is more important than the objects it represents. The reason being that once a class is defined, any number of objects of the class type can be churned out at the run time of the program. We also know that the class is a set of specifications that are used by the compiler for the purpose of construction of objects.

In fact for the creation of an object, the compiler creates a function having the same name as the class itself as shown in Fig. 6.1. It may be noted that the name of the class is myClass and the name of the function created by the compiler is also myClass. This function is called as a constructor function. As the name suggests, the constructor function creates an ...

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