123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
#include <iostream> #include <string> using namespace std; class Fraction { private: int numerator; int denominator; public: Fraction() { numerator = 1; denominator = 2; } Fraction(int n, int d) { numerator = n; denominator = d; } void print(); void multiply(Fraction,Fraction); }; void Fraction::print() { cout << numerator << "/" << denominator << endl; } void Fraction::multiply(Fraction,Fraction) { Fraction temp; } int main() { Fraction f1; Fraction f2(3,5); Fraction f3; f3.multiply(f1,f2); cout << "\nFraction Object f1\n"; f1.print(); cout << endl << endl; cout << "\nFraction Object f2\n"; f2.print(); cout << endl << endl; cout << "\nFraction Object f3\n"; f3.print(); cout << endl << endl; cout << endl; return 0; }
12
temp.numerator = f1.numerator * f2.numerator; temp.denominator = f1.denominator * f2.denominator;
f1.num *5 and f2.den *5