1136 - Experiment No 3
1136 - Experiment No 3
Date:17-6-2022
roll no-1136
program to demonstrate constructor overloding*/
#include<iostream.h>
#include<conio.h>
int ch;
class constr
{
public:
int a,b,c;
constr(int,int);
constr(float,float);
constr(int,int,int);
void putdata();
void putdata1();
};
constr::constr(int x,int y)
{
if(ch==1)
{
int c;
c=x+y;
cout<<"\nADDITION:"<<c;
}
if(ch==2)
{
int c;
c=x-y;
cout<<"\nSUBTRACTION:"<<c;
}
}
constr::constr(float x,float y)
{
if(ch==1)
{
float c;
c=x+y;
cout<<"\nADDITION:"<<c;
}
if(ch==2)
{
float c;
c=x-y;
cout<<"\nSUBTRACTION:"<<c;
}
}
{
int d;
d=a*b*c;
cout<<"\n\tMULTIPLICATION:"<< d;
void main()
{
static int x,y,z;
static float p,q;
while(1)
{
cout<<"\n\t1.ADDITION\n\t2.SUBTRACTION\n\t3.MULTIPLICATION\n\t4.EXIT";
cout<<"\n\tENTER YOUR CHOICE\t";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\n\tENTER TWO INTEGER NUMBERS\n";
cin>>x>>y;
constr c1(x,y);
cout<<"\n\tENTER TWO FLOAT NUMBER\n";
constr c2(p,q);
break;
case 2:
case 3:
break;
case 4:
break;
default:
cout<<"\n\tWRONG CHOLCE";
}
}
getch();
OUTPUT: