Implement the equality (==) and inequality (!=) operators for the Interval class. The first should be a member operator, and the second be a non-member operator. Two intervals are the same if their low and high data members are the same. interval.cpp 1 #include "interval.h" 2 3 |/ Implement the operators here... Tester.cpp 1 #include 2 #include "interval.h" 3 using namespace std; 4 5 int main() 6 { 7 Interval il(3, 4), i2(3, 4), i3(3, 5), 14(2, 4); cout « boolalpha; cout « "(3, 4) == (3, 4): cout « "Expected: true" <« endl; cout « "(3, 4) != (3, 4): " « (il != i2) « endl; cout « "Expected: false" <« endl; cout « "(3, 4) == (3, 5): cout « "Expected: false" <« endl; cout « "(3, 4) != (3, 5): cout « "Expected: true" <« endl; cout « "(3, 5) == (2, 4): " « (i3 == 14) « endl; cout « "Expected: false" <« endl; cout « "(3, 5) != (2, 4): " « (13 != 14) « endl; cout « "Expected: true" <« endl; 8 « (il == i2) « endl; 10 11 12 13 « (il == i3) « endl; 14 15 « (il != i3) « endl; 16 17 18 19 20

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

the second image is the header file i am given, please help me implement the two operators given in the instructions at the top of the image; in c++ please!

interval.h
1 #ifndef INTERVAL_H
2 #define INTERVAL_H
3
4 class Interval
{
6 public:
Interval (int lower, int upper);
bool operator==(const Interval& other) const;
9 private:
int low;
int high;
7
10
11
12 };
13
14
bool operator!=(const Interval& a, const Interval& b);
15
16
#endif
Transcribed Image Text:interval.h 1 #ifndef INTERVAL_H 2 #define INTERVAL_H 3 4 class Interval { 6 public: Interval (int lower, int upper); bool operator==(const Interval& other) const; 9 private: int low; int high; 7 10 11 12 }; 13 14 bool operator!=(const Interval& a, const Interval& b); 15 16 #endif
Implement the equality (==) and inequality (!=) operators for the Interval class. The first should
be a member operator, and the second be a non-member operator. Two intervals are the same if their
low and high data members are the same.
interval.cpp
1 #include "interval.h"
2
3 // Implement the operators here...
Tester.cpp
1 #include <iostream>
2 #include "interval.h"
using namespace std;
4
5 int main()
6 {
Interval il(3, 4), i2(3, 4), i3(3, 5), 14(2, 4);
cout « boolalpha;
cout « "(3, 4) == (3, 4):
cout « "Expected: true" <« endl;
cout « "(3, 4) != (3, 4):
cout « "Expected: false" <« endl;
cout « "(3, 4) == (3, 5): " « (il
cout « "Expected: false" <« endl;
cout « "(3, 4) != (3, 5): " « (il != i3) « endl;
cout « "Expected: true" < endl;
cout « "(3, 5)
cout « "Expected: false" <« endl;
cout « "(3, 5) != (2, 4): " « (13 != 14) « endl;
cout « "Expected: true" <« endl;
7
8.
9.
« (il == i2) « endl;
10
11
« (il != i2) « endl;
12
13
i3) « endl;
14
15
16
17
(2, 4):
« (13 == 14) <« endl;
18
19
20
21
Transcribed Image Text:Implement the equality (==) and inequality (!=) operators for the Interval class. The first should be a member operator, and the second be a non-member operator. Two intervals are the same if their low and high data members are the same. interval.cpp 1 #include "interval.h" 2 3 // Implement the operators here... Tester.cpp 1 #include <iostream> 2 #include "interval.h" using namespace std; 4 5 int main() 6 { Interval il(3, 4), i2(3, 4), i3(3, 5), 14(2, 4); cout « boolalpha; cout « "(3, 4) == (3, 4): cout « "Expected: true" <« endl; cout « "(3, 4) != (3, 4): cout « "Expected: false" <« endl; cout « "(3, 4) == (3, 5): " « (il cout « "Expected: false" <« endl; cout « "(3, 4) != (3, 5): " « (il != i3) « endl; cout « "Expected: true" < endl; cout « "(3, 5) cout « "Expected: false" <« endl; cout « "(3, 5) != (2, 4): " « (13 != 14) « endl; cout « "Expected: true" <« endl; 7 8. 9. « (il == i2) « endl; 10 11 « (il != i2) « endl; 12 13 i3) « endl; 14 15 16 17 (2, 4): « (13 == 14) <« endl; 18 19 20 21
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY