Difference Between Class And Object:

Difference Between Class And Object:


There are many differences between object and class. Some differences between object and class are given below:

ClassObject
Class is used as a template for declaring and 
creating the objects.      
An object is an instance of a class.
When a class is created, no memory is allocated.Objects are allocated memory space whenever they are created.
The class has to be declared first and only once.An object is created many times as per requirement.
A class can not be manipulated as they are not
available in the memory.
Objects can be manipulated.
A class is a logical entity.An object is a physical entity.
It is declared with the class keywordIt is created with a class name in C++ and 
with the new keywords in Java.
Class does not contain any values which 
can be associated with the field.
Each object has its own values, which are
associated with it.
A class is used to bind data as well as methods together as a single unit.Objects are like a variable of the class.

Syntax: Declaring Class in C++ is as follows: 

class <classname> {};

Syntax: Instantiating an object for a Class in C++ is as follows: 

class Student {

   public:

      void put(){

          cout<<“Function Called”<<endl;

      }

};   // The class is declared here

int main(){

         Student s1;   // Object created

         s1.put();

}

Example: BikeExample: Ducati, Suzuki, Kawasaki


Comments

Popular posts from this blog

Two Sum II - Input Array Is Sorted

Comparable Vs. Comparator in Java

Increasing Triplet Subsequence