//sample program illustrating simple fraction objects //illustrates use of "this" pointer // First compile the Fraction class: g++ -c Fraction.cc // -c means compile only producing Fraction.o // Then compile this main and link it to the methods in the // Fraction class: g++ mainFrac.cc Fraction.o // Then run the program with: a.out #include "Fraction.h" #include int main () { Fraction one; // 1/1 std::cout << one; // output using << op Fraction two (2), // 2/1 half (1, 2), // 1/2 third (1, 3); // 1/3 std::cout << two << (half + half); // needs gcd reduction Fraction temp = half.add (third); std::cout << temp << (half + third) << half.add (third) << std::endl; }