Question: Please note , you are required to include the following when you use g++ to compile: -pedantic For example: g++ -pedantic filename.cpp This will give

Please note, you are required to include the following when you use g++ to compile: -pedantic

For example:

g++ -pedantic filename.cpp

This will give a warning if you attempt to use any non-standard feature in g++. You must correct your code so that you do not receive any warnings of this type.

  1. Log on to the Linux server.
  2. Create four files:
  1. Rational.h
  2. Rational.cpp
  3. RationalMain.cpp
  4. Makefile
  1. In Rational.h:

#ifndef _RATIONAL_H_

#define _RATIONAL_H_

#include

using namespace std;

class Rational

{

int _p;

int _q;

public:

Rational();

Rational(int P, int Q = 1);

void display() const; // _p:_q

void add(const Rational&);

void sub(const Rational&);

void mult(const Rational&);

void div(const Rational&);

};

#endif

In Rational.cpp, implement these member functions. You must make sure that you never have

_q zero[1]. Your Rational number must be stored in reduced form, that is, _p and _q must be relatively prime.

You must not use any built-in functions

In RationalMain.cpp, write a test main to test your code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!