class Farey { private: int Top, Bottom; public: Farey(); Farey(int T, int B); Fa
ID: 3666697 • Letter: C
Question
class Farey {
private: int Top, Bottom;
public:
Farey();
Farey(int T, int B);
Farey operator+(const Farey& RHS) const;
Farey operator-(const Farey& RHS) const;
bool operator==(const Farey& RHS) const;
void Display(ostream& Out) const;
};
Farey::Farey() {
Top = Bottom = 0;
}
Farey::Farey(int T, int B) {
Top = T; Bottom = B;
}
Farey Farey::operator+(const Farey& RHS) const {
return Farey(Top + RHS.Top, Bottom + RHS.Bottom);
}
Farey Farey::operator-(const Farey& RHS) const {
return Farey(Top - RHS.Top, Bottom - RHS.Bottom);
}
bool Farey::operator==(const Farey& RHS) const {
return ( (Top == RHS.Top) && (Bottom == RHS.Bottom) );
}
void Farey::Display(ostream& Out) const { Out << Top << '/' << Bottom; }
consider the following code fragment:
Farey A(3, 5), B(1, 4), C(2, 4), D(0, 5), E;
E = A + B; // line 1
A.Display(cout); // 2
E = A + B; // 3
E=E- C; //4
E.Display(cout);
After the execution of line 4, what is the values of E.Display(cout)?
A) 3/5
B) 2/5
C) Error
D) Not known
Explanation / Answer
C) Error
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.