#include <iostream>
using namespace std;
class Distance
{
private:
int feet,inches;
public:
void readDistance(void)
{
cin >>feet;
cin >>inches;
}
void dispDistance(void)
{
cout << "Feet:" << feet << " " << "Inches:" << inches << endl;
}
Distance operator +(Distance &dist1)
{
Distance tempD;
tempD.inches= inches + dist1.inches;
tempD.feet = feet + dist1.feet + (tempD.inches/12);
tempD.inches=tempD.inches%12;
return tempD;
}
};
int main()
{
Distance D1,D2,D3;
D1.readDistance();
D2.readDistance();
D3=D1+D2;
D3.dispDistance();
return 0;
}
using namespace std;
class Distance
{
private:
int feet,inches;
public:
void readDistance(void)
{
cin >>feet;
cin >>inches;
}
void dispDistance(void)
{
cout << "Feet:" << feet << " " << "Inches:" << inches << endl;
}
Distance operator +(Distance &dist1)
{
Distance tempD;
tempD.inches= inches + dist1.inches;
tempD.feet = feet + dist1.feet + (tempD.inches/12);
tempD.inches=tempD.inches%12;
return tempD;
}
};
int main()
{
Distance D1,D2,D3;
D1.readDistance();
D2.readDistance();
D3=D1+D2;
D3.dispDistance();
return 0;
}
#include
ReplyDeleteusing namespace std;
class Distance
{
private:
int feet,inches;
public:
void readDistance(void)
{
cin >>feet;
cin >>inches;
}
void dispDistance()
{
cout << "Feet:" << feet << " " << "Inches:" << inches << endl;
}
Distance operator +(Distance &dist1)
{
Distance tempD;
tempD.inches= inches + dist1.inches;
tempD.feet = feet + dist1.feet + (tempD.inches/12);
tempD.inches=tempD.inches%12;
return tempD;
}
};
int main()
{
Distance D1,D2,D3;
D1.readDistance();
D2.readDistance();
D3=D1+D2;
D3.dispDistance();
return 0;
}