Search This Blog

Thursday, July 2, 2020

Object and Class in c++

Mr. abhijeet dwivedi
Object and Class in C++

In this tutorial you will learn

Object(Instance of classes):-

It is a piece of code which represent the real life entity and this is created in runtime.
* It combine data & function.
* Object also give a life to class.
* Object can be manipulated.
* Object occupy the memory location.
* It is also instance of classes.

For example:-


In the above figure, you can see a car so car have a some attributes like color, speed, model,etc and functionality like get speed, get fuel, etc.
Then the all attributes and functionally of car is OBJECT.
And, Car is class.

Class:-

Collection of similar object(Homogeneous) is called class.
* Class is also a user define function.
* Class can not be manipulated cause it is not available memory except static class.
* Class does not occupy memory location.

Syntax of class

Class class name
{
Private:    ------------------Hide data
variable declaration;
function;
Public:     ---------------------- Private data
function and variable;
};



Differentiate between Object and Class:-

               OBJECT

       CLASS

                                                   

 1.

Object is an instance of class

Class is a collection of similar object.

 2.

Object gives life to the class

The class can be generate by object.

 3.

Object occupy memory loaction

Class can not occupy memory location.

 4.

Object can be manipulated.

Class can not be manipulated cause it is not available memory except static class