#include<iostream>
using namespace std;
class Distance
{
private:
int feet,inches;
public:
Distance()
{
feet=0;inches=0;
}
Distance(int f,int i)
{
feet = f;
inches = i;
}
Distance operator ()(int M)
{
Distance D;
D.feet=M*3.25;
D.inches=M*40;
return D;
}
void display()
{
cout<<"Feet : "<<feet<<" Inches :"<<inches<<endl;
}
};
int main()
{
Distance d1,d2(11,10),d3;
cout<<" Constructor 1 for Distance "<< endl;
d1.display();
cout<<" Constructor 2 for Distance "<< endl;
d2.display();
cout<<"operator () to convert meter into feets and inches"<<endl;
d3=d2(20);
d3.display();
return 0;
}
output:
Constructor 1 for Distance
Feet : 0 Inches :0
Constructor 2 for Distance
Feet : 11 Inches :10
operator () to convert meter into feet's and inches
Feet : 65 Inches :800
0 Comments
Post a Comment