#ifndef _RATIONAL_H #define _RATIONAL_H #pragma once #include class Rational { // declare input and output operators functions as friends // to the class so they can directly access the private data friend std::istream& operator>>(std::istream& is, Rational &r); friend std::ostream& operator<<(std::ostream& os, const Rational &r); public: // constructor Rational(int n = 0, int d = 1); // sets to n / d bool set(int n, int d); // accessor functions int num() const; int den() const; // returns decimal equivalent double decimal() const; //overload + Rational operator+(const Rational &r2) const; private: int num_, den_; // numerator and denominator }; // prototype for operator< standalone function bool operator<(const Rational& r1, const Rational& r2); #endif