#include<iostream.h>
class Float
{
private:float a;
public: Float()
{
a=0;
}
Float(float a1)
{
a=a1;
}
Float operator+(Float c)
{
Float d;
d.a=a+c.a;
return d;
}
Float operator-(Float c)
{
Float d;
d.a=a-c.a;
return d;
}
Float operator*(Float c)
{
Float d;
d.a=a*c.a;
return d;
}
Float operator/(Float c)
{
Float d;
d.a=a/c.a;
return d;
}
void show()
{
cout<<a;
}
};
void main()
{
Float m1(1.25),m2(2.25),m;
m=m1+m2;
cout<<"Addition=";
m.show();
m=m1-m2;
cout<<"\nSubtraction=";
m.show();
m=m1*m2;
cout<<"\nMultiplication=";
m.show();
m=m1*m2;
cout<<"\nDivision=";
m.show();
//cout<<m;
}
class Float
{
private:float a;
public: Float()
{
a=0;
}
Float(float a1)
{
a=a1;
}
Float operator+(Float c)
{
Float d;
d.a=a+c.a;
return d;
}
Float operator-(Float c)
{
Float d;
d.a=a-c.a;
return d;
}
Float operator*(Float c)
{
Float d;
d.a=a*c.a;
return d;
}
Float operator/(Float c)
{
Float d;
d.a=a/c.a;
return d;
}
void show()
{
cout<<a;
}
};
void main()
{
Float m1(1.25),m2(2.25),m;
m=m1+m2;
cout<<"Addition=";
m.show();
m=m1-m2;
cout<<"\nSubtraction=";
m.show();
m=m1*m2;
cout<<"\nMultiplication=";
m.show();
m=m1*m2;
cout<<"\nDivision=";
m.show();
//cout<<m;
}
No comments:
Post a Comment