Mujhe is Program ki Missing Function Bodies Chahye.
Comments Ke Mutabiq.
Please Koi Help Kare.
Mujhe Ye Aaj Raat Tak Chahye Lazmi.




#include <iostream>
#include <sstream>
using namespace std;
class Fraction
{
int *numerator, *denominator;
public:
Fraction(int num=0, int den=1)
{
//dynamically declare numerator and denominator, initialize numerator to num and
//denominator to den
}
void setNumerator(int num)
{
//assign num to numerator
}
void setDenominator(int den)
{
//assign den to denominator
}
void setFraction(int num, int den)
{
//assign num to numerator and den to denominator
}
int getNumerator()
{
//return numerator's value
}
int getDenominator()
{
//return denominator's value
}
long double getValue()
{
//divide numerator by denominator and return the answer as long double
//hint: use type casting
}
void simplify()
{
//simplify the fraction. e.g. 21/12 = 7/4, 25/5 = 5/1, 24/44 = 6/11,
//10/15 = 2/3, etc
}
Fraction add(Fraction f)
{
//add f to the current fraction(through which the function is being called)
//and return the result as a fraction
//e.g. Fraction f1(2,3), f2(4,5); f1.add(f2); here f1 is the current fraction
//and f2 will be mapped onto the input parameter 'f'
//you'll have to add two fractions, the current one and f like fractions are added
//for hint, see multiply and divide below
}
Fraction subtract(Fraction f)
{
//subtract f from current fraction and return the result as a fraction. a clever
//solution will be to use add function for subtraction
//as a-b = a+(-b). for hint, see the divide function below.
}
Fraction multiply(Fraction f)
{
Fraction temp(*numerator * f.getNumerator(), *denominator * f.getDenominator());
return temp;
//*numerator and *denominator belong to current fraction and f.getNumerator() and
//f.getDenominator() will return f's numerator and denominator respectively
//the above can also be achieved by doing the following statement. its known as
//returning temporary unnamed object
//return (Fraction(*numerator * f.getNumerator(), *denominator * f.getDenominator()));
}
Fraction divide(Fraction f)
{
Fraction temp(f.getDenominator(), f.getNumerator());
//temp will be equal to f's reciprocal
return multiply(temp); //because (2/3)/(4/5) = (2/3)*(5/2)
}
bool isEqual(Fraction f)
{
return getValue() == f.getValue();
}
bool isLessThan(Fraction f)
{
return getValue() < f.getValue();
}
bool isLessThanOrEqual(Fraction f)
{
return getValue() <= f.getValue();
}
bool isGreaterThan(Fraction f)
{
return getValue() > f.getValue();
}
bool isGreaterThanOrEqual(Fraction f)
{
return getValue() >= f.getValue();
}
bool isNotEqual(Fraction f)
{
return getValue() != f.getValue();
}
string toString()
{
if(*denominator==0) return "UNDEFINED";
if(*numerator==0) return "0";
ostringstream output;
if(*denominator==1) output<<*numerator;
else output<<*numerator<<'/'<<*denominator;
return output.str();
}
void display()
{
cout<<toString();
}
};