Fraction Class With Overloaded Ops

Previous      Next      f1.cc      frac.1.h      frac.1.cc

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include "frac.1.h"
using namespace std;

int main () {
   Fraction *a = new Fraction(2,3);
   cout << "The a fraction is "; a->display();
   getchar();
   
   Fraction *b = new Fraction(3,4);
   cout << "The b fraction is "; b->display();
   getchar();
	
   a->display(); cout << " * "; b->display(); cout << " = ";
   a->times(b)->display();
   getchar();
	
   a->display(); cout << " / "; b->display(); cout << " = ";	
   a->over(b)->display();
   getchar();
	
   a->display(); cout << " + "; b->display(); cout << " = ";	
   a->plus(b)->display();
   getchar();
	
   a->display(); cout << " - "; b->display(); cout << " = ";	
   a->sub(b)->display();
   getchar();
	
   cout << "(a - b)*b = "; (a->sub(b))->times(b)->display();
   getchar();
}