06 - C++ Objects

An object is an instance of a class. When you declare an object, memory is allocated to it. Each object of a class has its own set of attributes (variables) of that class and can access member functions of a class. Let us declare an object of the date class:

date date1;  

date1 is an object of the type date.

Objects cannot access private members of a class directly.

date1.dd =10;                               an invalid statement

However, you can use the member functions of the same class to access private members of that class.

date1.valid (10,12);                       is a valid statement

Like us on Facebook