Tuesday, 5 March 2019

How to perform Overloading of constructors || Learn c++ coding



   Program to perform overloading of constructors.




1. First open a turbo c++ compiler 

2. Now click on new and copy the code given below.

#include<iostream.h>
#include<conio.h>

class A
{ public: A()
{cout<<"\n This is a constructor with no arguments";

}
A(int x)
{int y=x;
 cout<<"\nThis is a constructor with one argument and value received is"<<y;
}

};

void main()
{clrscr();
A obj1;
A obj2(20);
getch();


}



Now run the code and output will be:-


1 comment:

👇 🌐 Top 10 Hosting for Developers in 2025: Fast, Reliable & Affordable

 Whether you’re a beginner building your first portfolio site or a professional developer deploying client projects, choosing the right host...