/**************************************************************** example 01 -- driver.cpp 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; } void main() { length joey(4,5); cout << "Joey's height was: "; joey.show(); cout << endl; cout << "Then Joey grew 6 inches." << endl; joey.grow(0.5); cout << "Joey's new height was: "; joey.show(); cout << endl; }