Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I can\'t get the program to get past the first line shown in main.It will read i

ID: 3613974 • Letter: I

Question

I can't get the program to get past the first line shown in main.It will read in Rational c and Rational d but get an error onRational x. In the header file are the only functions I can use.Below is my program so far. Please help.

Here is main.
#include <iostream>
#include "Rational.h"
using namespace std;

int main()
{
   Rational c(1, 3), d(7, 9), x;
    return 0;
}

Here is the Rational.h file
#include<iostream>
#ifndef _RATIONAL_H_
#define _RATIONAL_H_

class Rational
{
public:
    Rational(int Num, int Denom);
    Rational(const Rational &obj);

    Rational &operator=(const Rational&rhs);
    bool operator==(const Rational &rhs);
    bool operator>(const Rational &rhs);
    bool operator<(const Rational &rhs);

    Rational operator+(const Rational &rhs);
    Rational &operator+=(const Rational&rhs);
    Rational operator-(const Rational &rhs);
    Rational &operator-=(const Rational&rhs);

    Rational operator*(const Rational &rhs);
    Rational &operator*=(const Rational&rhs);
    Rational operator/(const Rational &rhs);
    Rational &operator/=(const Rational&rhs);

    operator float();

private:
    int numerator;
    int denominator;
    int totalNumerator;
    int totalDenominator;
}
#endif

Here is Rational.cpp file
#include "Rational.h"
#include<iostream>
using namespace std;
//**********************************************************
// This function stores the numerator and the denominator. *
//**********************************************************
Rational::Rational (int num, int denom)
{
    numerator = num;
    denominator = denom;
}

Rational::Rational(const Rational &obj)
{
    numerator = 0;
    denominator = 0;
}

Explanation / Answer

Dear, It have no definatition of Rational(), so it's giving compiler error. //Rational.cpp #include "Rational.h" #include using namespace std; //********************************************************** // This function stores the numerator and the denominator. * //********************************************************** Rational::Rational (int num, int denom) {     numerator = num;     denominator = denom; } Rational::Rational(const Rational &obj) {     numerator = 0;     denominator = 0; } Rational::Rational() { numerator = denominator = 0; } //Rational.h #include #ifndef _RATIONAL_H_ #define _RATIONAL_H_ class Rational { public:     Rational(int Num, int Denom);     Rational(const Rational &obj);     Rational();     Rational &operator=(const Rational&rhs);     bool operator==(const Rational &rhs);     bool operator>(const Rational &rhs);     bool operator
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote