/****************************************************************
example 2 -- length.h
feet/inches manager
****************************************************************/
#include <iostream>
using namespace std;
//class definition
class length {
private:
int feet;
int inches;
public:
length(const int& f = 0, const int& i = 0);
void show(ostream& out = cout) {
out << feet << '\'' << inches << '"';
}
void grow(const float& = 1.0);
};
length::length(const int& f, const int& i) {
if (f > 0)
feet = f;
else
feet = 0;
if (i > 0) {
feet += i / 12;
inches = i % 12;
}
else
inches = 0;
}
void length::grow(const float& f) {
feet += (int)f;
int temp = inches + f * 12;
inches = temp % 12;
}