i have the following for my operator overload
fraction fraction::operator+(const fraction& object)const
{
fraction temp;
temp.a = a*object.b + b*object.a;
temp.b = b * object.b;
return temp;
}
fraction fraction::operator-(const fraction& object) const
{
fraction temp;
temp.a = a*object.b - b*object.a;
temp.b = b * object.b;
return temp;
}
fraction fraction::operator*(const fraction& object)const
{
fraction temp;
temp.a = a*object.b * b*object.a;
temp.b = b * object.b;
return temp;
}
fraction fraction::operator/(const fraction& object)const
{
fraction temp;
temp.a = a*object.b / b*object.a;
temp.b = b * object.b;
return temp;
}
<< moderator edit: added [code][/code] tags >>
but am getting the wrong output. Is my algorithm wrong ? if so how can i correct ?