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:-


Comments

Popular posts from this blog

Java Project Code: Cinema Ticket booking system : Create a Java Application to book a ticket in a Cinema hall.