Answer:
The program in C++ is as follows:
class Rational {
public:
void reduce(int num, int denom) {
int d = __gcd(num, denom);
num /= d;
denom /= d;
cout << "Fraction: " << num <<"/" << denom << endl;
}
int num; int denom;
};
int main() {
int numerator, denominator;
cout<<"Numerator: "; cin>>numerator;
cout<<"Denominator: "; cin>>denominator;
Rational myObj;
myObj . num = numerator;
myObj . denom = denominator;
myObj . reduce(myObj . num,myObj . denom);
return 0;
}
Explanation:
In order to be able to submit my solution, I had to remove and alter some parts of the program.
I've added the complete program as an attachment where I used comments to explain each line of the program