Parameterized constructor in C++ Example

Parameterized constructor in C++ Example
/********************************************************************************************************
*************Designed and Developed by V2Geeks******************************************
********************************************************************************************************/

//Example of Parameterized constructor
#include<iostream.h>
#include<conio.h>
class  A {
   int a,b;
    public:
    A() //This is Default constructor
    {
cout<<"Hello from default constructor"<<endl;
    }
A(int x,int y)          //This is parameterized  constructor
   //initialization of a and b at the time of object creation
  a=x;
  b=y;
   }
void sum()
        {
        cout<<"a+b="<<a+b<<endl ;
}
 } ;
void main()
{
clrscr();
        A objD;           //Now it will call Default constructor
        A objA(10.25,20) ; //Here A(int,int) is parameterized constructor
        objA.sum();
        getch();
}
Reactions: