(10%) Determine
whether the syntax of the following code is correct or not. If it
is
correct, predict its output. If it is incorrect, point out the
mistake(s).
// Function Overloading
#include <iostream>
class Rational {
public:
Rational(int n = 0, int d = 1) // Constructor
: numerator(n), denominator(d) {}
Rational(Rational&
b)
// same function name
: numerator(b.numerator), denominator(b.denominator) {}
void print() {
std::cout << numerator << '/' << denominator << ' '; }
private:
int numerator;
int denominator;
};
int main() {
Rational a;
Rational b(2);
Rational c(1,2);
Rational d(b);
a.print(); b.print(); c.print(); d.print();
return 0;
}