Question: Self-Test Exercise 17 asked you to overload the operator >> and the operator int parameters. The one-parameter constructor should initialize the first member of the

Self-Test Exercise 17 asked you to overload the operator >> and the operator int parameters. The one-parameter constructor should initialize the first member of the pair; the second member of the pair is to be 0.

Overload binary operator+ to add pairs according to the rule

(a, b) + (c, d) = (a + c, b + d)

Overload operator analogously.

Overload operator* on pairs and int according to the rule

(a, b) * c = (a * c, b * c)

Write a program to test all the member functions and overloaded operators in your class definition.

using this tempalte

Self-Test Exercise 17 asked you to overload the operator >> and theoperator int parameters. The one-parameter constructor should initialize the first member of

#include using namespace std; class Pair public: Pair(); Pairint first, int second); Pair (int first); int access First(); int accessSecond(); // other members and friends friend Pair operator+(const Pairs, const Pairt); friend Pair operator (const Paire, int); friend istream& operator>> (istreams, Paint); friend ostream& operator> (istreame ins, Pairt second) //Complete the function } ostreamt operatorss (ostreams outs, const Pairt second) 1/Complete the function 1 Pair::Pair(int firstValue, int secondValue) f(firstValue), s (secondValue) [//Complete the function { Pair: Pair(int firstValue) f (firstValue), 5(0) {/Complete the function Pair::Pair(): (0), (0) {//Complete the function } int Pair: accessfirst) { Complete the function } int Pair: accessSecond) { //Complete the function

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!