C++ Objects

Objects are used to access the class members. The creation of an object is simple and this process is known as instantiating an object. And to create an object we have the ‘new’ operator.

Syntax:            class-name  object-name;

Object-name = new class-name();

In the first line we are just declaring an object. And in the next line we are instantiating it with the new operator.

And class is not occupied any space in memory. But the objects after instantiating take space in memory according to the type and number of instance variables.

e.g:      student  obj;

obj = new  student();

Leave a Reply

Your email address will not be published. Required fields are marked *