I'm not sure if I am misunderstanding or not, but I've been tasked with creating a function that adds fractions to the nth term. Though I'm not exactly sure how to do that without using a mutator. If I understand correctly. I must pass the add function the Rational h for it to properly work, would I just pass it Rational h and then completely ignore Rational h as I do not want to mutate it?
What exactly am I to do with my result? Run it directly into a print function from my add function?
rational_test.cpp
1 2 3 4 5 6 7 8 9
Rational h;
int n;
cout << "Now runnning rational.cpp" << endl;
cout << "The harmonic series is the following infinite series: '1 + 1/2 + 1/3 + ...'" << endl;
cout << "Finding H(10) of the series" << endl;
n = 10;
h.add(n);//Run function add to find H(10)
class Rational
{
private:
longint numerator;
longint denominator;
public:
Rational(); // Default constructor
Rational(constlongint, constlongint);
//
// add
//
//Purpose- An arithmetic addition operation that adds one instance of Rational to another
//
//Parameter(s)-
// n: the number of terms that will be added
//Precondition(s)- N/A
//
//Returns-
//
//Side Effect-
//
//
void add(constint) const;
rational.cpp
1 2 3 4 5 6
//NONE of the member functions should be mutation operation.
//Declare all member functions to be const member functions.
void Rational::add(constint n) const
{
}