As you've discovered, trying to use arithmetic operators on pointers will result in the compiler trying to do pointer arithmetic. To call your own overloaded operator on a pointer, you can either do
Fraction *f, *g; // allocated with new
f->operator+(*g); /// Urgh!
or, almost as ugly
Fraction *f, *g;
(*f) + (*g);
One easy way to make this a bit nicer is to declare three new reference variables like this:
Fraction& f1 = *pfr1;
Fraction& f2 = *pfr2;
Fraction& f3 = *ptr3;
Where the pfrN
s are the pointers to your fractions. Now if you use the reference variables, your overloaded operators will be called correctly, and you don't need to put in all the extra asterisks. The references will disappear at the end of the scope, and probably won't use any extra memory in your programme. You still need to delete
the original pointers though!