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:-
Well done
ReplyDelete