Home » Learn C++ » Objects in C++

Objects in C++

Objects in C++:

            A data type is used to declare a variable. A variable of a data type is also known as the instance or case of that data type. Each variable has a unique name but each variable follows the rules of its data type. When a variable of a data type is declared, some space is reserved for it in the memory.

 

A class is also like a data type. It is therefore used to declare variables or instances. The variables or instances of a class are called objects. A class may contain several data items and functions. Thus the object of a class consists of both the data members and the member functions of the class. The combining of both the data and the functions into one unit is called data encapsulation.

 

            An object represents data members of’ a class in the memory. Each object of a class has a unique name. The name of an object differentiates it from other objects of the same class. The values of data members of different objects may he different or same. The values of data members in an object are known as the state of the object.

 

            The functions in an object are called the member functions. They are also known as the methods. The member functions arc used to process and access data of the object. For example, the data from an object is accessed and processed through the member function of the object. It cannot directly read the data in the object. The data is hidden for other objects of the program. This is called data hiding. The data hiding and data encapsulation are the main features of Object Oriented Programming.

 

Other Topics

comment closed

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
Copyright © 2010 Information Village. All rights reserved.