Modify the FeetInches class discussed in this chapter so it overloads the follow
ID: 3537088 • Letter: M
Question
Modify the FeetInches class discussed in this chapter so it overloads the following operators:
<=
>=
!=
Demonstrate the class's capabilities in a simple program.
Grading:
1. Prototypes for three new operators added to FeetInches.h file
2. Code for overloaded >= added to FeetInches.cpp file.
Has proper return value and object parameter
Has proper return value and object FeetInches parameter
Checks if the current object is less than or equal to the parameter and returns.
4. Code for overloaded != added to FeetInches.cpp file.
Has proper return value and object parameter
Checks if the current object is equal to the parameter and returns.
These are my codes for the files that I have so far:
This is to test the two programs:
Be sure include the entire program with the changes you make. Help would be greatly appreciated!
Explanation / Answer
//Main file
#include <iostream>
#include "FeetInches.h"
using namespace std;
int main()
{
// Create three FeetInches objects.
FeetInches one, two, three;
// Get a distance for the first object.
cout << "Enter a distance in feet and inches: ";
cin >> one;
// Get a distance for the second object.
cout << "Enter another distance in feet and inches: ";
cin >> two;
// Test the != operator.
if (one != two)
cout << "The two are not equal. ";
// Test the >= operator.
if (one >= two)
cout << one << " is >= " << two << endl;
// Test the <= operator.
if (one <= two)
cout << one << " is <= " << two << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.