Class and Object

Class -A class is a blue print for creating objects.


A class is a group of objects which show a common property.


A class is a collection of objects of similar type.Once a class is defined, any number of objects can be created which belong to that class.For example – Define a class to print the values of two numbers.

Class HelloWorld


    int one;

    int two;


    void setdata()


        cout<<”enter two numbers”;



     void putdata()





int main()


     HelloWrold obj;



     return 0;


Classes are generally declared using the keyword class, with the following format:

class class_name








Object -It may be defined as identifiable identity with some characteristics and behavior.

Syntax of creating Object:

Class_name Object_Name;

If we have class named AB then the Object of this class can be created using above syntax as

AB Obj;

Abstract class

An abstract class is a class that is designed to be specifically used as a base class. An abstract class contains at least one pure virtual function.

You declare a pure virtual function by using a pure Specifier

(= 0) in the declaration of a virtual member function in the class declaration.

The following is an example of an abstract class:

class AB {


            virtual void f() = 0; //Pure virtual Function


Concrete class – It is a derived class that implement all the missing functionality of a abstract class.

The following is an example of an concrete class: 

 class CD : public AB //Here class AB is abstract class

{                     // Declare Above

           {   // set up the CD   } 
   virtual f()   // implementation of f() of class AB


           /* do stuff of f() */

Advantages and disadvantages of Object Oriented Programming

    Advantages –

  1. 1.Re-usability of code.
  2. 2.Ease of redesign and extension.
  3. 3.Data can be divided as public and private.(data protection)
  4. 4.Program development becomes easy due to increased modularity.(abstraction and encapsulation)

    Disadvantages –

  1. 1.The relation among classes become artificial at times
  2. 2.The object oriented programming design id difficult.
  3. 3.OOP is a high level concept so takes more time to execute as many routines run behind at the time of execution.
  4. 4.Offers less number of functions as compared to low level programming which interacts directly with hardware.