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:

DBMS NOTES UNIT 3

                                                              UNIT 3  ER (Entity Relationship) An entity-relationship model is known as an E...