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:

Java Unit Wise Notes

 JAVA Notes   --- UNIT-I DETAILED NOTES (JAVA) 1. History of Java Developed by James Gosling at Sun Microsystems (1991–1995). Initia...