Define a class Pairs with two integer data members, f and s, where f represents

the first value in the ordered pair and s represents the second value in an ordered

pair. Objects of type Pairs can be used in any situation where ordered pairs are

needed. This class has:

The class should contain a default constructor that initializes both data members to

0, and two overloaded constructors, one with one int parameter and the other with

two int parameters. The one-parameter constructor should initialise the first

member of the pair; the second member of the pair is to be 0. The two-parameter

constructor should initialise both members of the ordered pair.

The class should also contain a destructor that outputs the message "Goodbye!"

Include accessor functions that return the values stored in each of the member

variables of an object of class Pairs (i.e. get functions), as well as mutator

functions to update each of the member variables of an object of class Pairs

respectively (i.e. set functions with a parameter to set each member variable to a

value specified by the parameter). The class should also contain a void member

function called reset() that resets the member variables of a Pairs to values

specified by parameters.

Overload the stream extraction operator >> and the stream insertion operator << as

friend functions so that objects of class Pairs are to be input and output in the

form (5,6) (5,-4) (-5,4) or (-5,-6).

Overload binary operator + as a friend function to add pairs according to the rule

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

Overload operator – as a friend function in the same way, i.e. according to the rule

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

Overload operator * as a friend function 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.