Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention. Check out this how-to article for more information.
#ifndef RATIONALNUMBER_H
#define RATIONALNUMBER_H
using namespace std;
class RationalNumber
{
friend RationalNumber operator+ (RationalNumber);
friend RationalNumber operator- (RationalNumber);
friend RationalNumber operator/ (RationalNumber);
friend RationalNumber operator* (RationalNumber);
public:
RationalNumber(int numerator, int denominator);
System::String^ toString();
int getNumerator();
int getDenominator();
RationalNumber operator+ (const RationalNumber& r) const;
RationalNumber operator- (const RationalNumber& r) const;
RationalNumber operator/ (const RationalNumber& r) const;
RationalNumber operator* (const RationalNumber& r) const;
private:
int _numerator;
int _denominator;
int _wholeNumber;
bool isValidDenominator(const int denominator);
void simplifyFraction();
};
#endif
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
#ifndef RATIONALNUMBER_H
#define RATIONALNUMBER_H
using namespace std;
// foward declaration
RationalNumber operator/ (const RationalNumber& l, const RationalNumer& r);
class RationalNumber
{
// 'friend' is only necessary for non-members
friend RationalNumber operator/ (const RationalNumber& l, const RationalNumer& r);
public:
RationalNumber(int numerator, int denominator);
System::String^ toString();
int getNumerator();
int getDenominator();
RationalNumber operator+ (const RationalNumber& r) const;
RationalNumber operator- (const RationalNumber& r) const;
RationalNumber operator/ (const RationalNumber& r) const;
RationalNumber operator* (const RationalNumber& r) const;
private:
int _numerator;
int _denominator;
int _wholeNumber;
bool isValidDenominator(const int denominator);
void simplifyFraction();
};
#endif
// ...
RationalNumber operator/ (const RationalNumber& l, const RationalNumer& r);
{
// implement here
}
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.