Question: - FeetInche s Class Copy Constructor and multiply Function Add a copy constructor to the FeetInches class. This constructor should accept a FeetInches object as

- FeetInche s Class Copy Constructor and multiply Function

Add a copy constructor to the FeetInches class. This constructor should accept

a FeetInches object as an argument. The constructor should assign to the feet

attribute the value in the arguments feet attribute, and assign to the inches attribute

the value in the arguments inches attribute. As a result, the new object will be a copy

of the argument object.

Next, add a multiply member function to the FeetInches class. The multiply

function should accept a FeetInches object as an argument. The argument objects

feet and inches attributes will be multiplied by the calling objects feet and inches

attributes, and a FeetInches object containing the result will be returned.

1. Redefine relational operators ( >,<,==,!=,==,>=,

2. Redefine arithmetic operators.

3. Redefine stream operators

4. Overloaded constructor functions

5. Mutator functions

6. Accessories functions

Implement the original problem and add the operators defined in the

version 4 of FeetInches.h (Highlighted in yellow)

Implement a menu of options and switch/case to demonstrate each of the

their operations with the given examples.

#ifndef FEETINCHES_H

#define FEETINCHES_H

#include

using namespace std;

class FeetInches; // Forward Declaration

// Function Prototypes for Overloaded Stream Operators

ostream & operator

istream & operator >> (istream &, FeetInches &);

// The FeetInches class holds distances or measurements

// expressed in feet and inches.

class FeetInches

{

private:

int feet; // To hold a number of feet

int inches; // To hold a number of inches

void simplify (); // Defined in FeetInches.cpp

public:

// Constructor

FeetInches (int f = 0, int i = 0)

{

feet = f;

inches = i;

simplify ();

}

// Mutator functions

void setFeet (int f)

{

feet = f;

}

void setInches (int i)

{

inches = i;

simplify ();

}

// Accessor functions

int getFeet () const

{

return feet;

}

int getInches () const

{

return inches;

}

// Overloaded operator functions

FeetInches operator + (const FeetInches &); // Overloaded +

FeetInches operator - (const FeetInches &); // Overloaded -

FeetInches operator ++ (); // Prefix ++

FeetInches operator ++ (int); // Postfix ++

bool operator > (const FeetInches &); // Overloaded >

bool operator

bool operator == (const FeetInches &); // Overloaded ==

// Friends

friend ostream & operator

friend istream & operator >> (istream &, FeetInches &);

};

#endif

Attachments:

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 Programming Questions!