A constructor is a special type of member function which get activated when the instance of a class
is created.A constructor name and class are same.A constructor doesn't return any value not even
void but may receive any types of argument there for the constructor can be overloaded.
(overloading means , a class share a function having same name but different arguments.)
Constructor overloading program.
class Demo
{
public Demo() // default constructor
{
cout<<"Default constructor call";
}
public Demo(int a) // constructor with one parameter
{
cout<<"Constructor with one parameter:"<
}
public Demo(int a,int b) // constructor with two parameter
{
cout<<"Constructor with two parameter:"<
}
}
void main()
{
Demo d1; // here default constructor will invoke(call automatically)
Demo d2(10);//here one parameter constructor will invoke(call automatically)
Demo d3(5,10)// here two parameter constructor will invoke(call automatically)
}