Multiple constructor overloaded in c++ example

Multiple constructor overloaded in c++ example


/********************************************************************************************************
*************Designed and Developed by V2Geeks******************************************
********************************************************************************************************/

//Example of Multiple constructor(overloaded )in a class
#include<iostream.h>
#include<conio.h>
class A
{
         public:
         A()       //   default constructor
         {
                cout<<"Hello from default constructor"<<endl;
 }
        A(int a) //single integer type parameterized constructor
         {
                cout<<"Hello from single parameterized constructor"<<endl;
}
        A(int a,int b)  // double integer type parameterized constructor
{
                cout<<"Hello from double parameterized constructor"<<endl;
 }
         A(char a,char b) //double character type parameterized constructor
         {
                cout<<"Hello from double parameterized char constructor"<<endl;
}
};
void main()
{
        A objA1 ;         //it will call default constructor
        A objA2(5,10);  //it will call double integer 
                        //type parameterized constructor
          A objA3(5);     //it will call single integer type parameterized constructor
        A objA4('x','y'); //it will call double character type parameterized constructor
}
Reactions: