Show how to overload the operators << and >> to create stream output for this class. Make these functions friends of the class Pair. The expected form of a pair is (2,3) for both input and output. To make this problem manageable, you should only provide to accept and discard the parentheses and comma, but you should not check that these particular characters were typed. Output should be the expected form.

```
class IntPair
{
int first;
int second;
public:
IntPair(int firstValue, int secondValue);

int getFirst( ) const; int getSecond( ) const;};

```
What will be an ideal response?


```
#include
using namespace std;//Class with friend declarations:
class IntPair{ int first;
int second;
public:
IntPair(int firstValue, int secondValue);
friend int operator>>(int,IntPair);

friend istream& operator>>(istream& intStr,
IntPair& pair);
friend ostream& operator<<(ostream& outStr,
const IntPair& pair);
int getFirst( ) const; int getSecond( ) const;}; //Definitions
istream& operator>>(istream& inStr,IntPair& pair)
{
// only vestigial checking. Expect the form (1,2)
char ignore; // for ( , and ). inStr >> ignore >>
pair.first >> ignore >> pair.second
>> ignore;
return inStr;
}
ostream& operator<<(ostream& outStr,const IntPair& pair)
{outStr << "(" << pair.first << ", "
<< pair.second << '', ''
return outStr;
```

Computer Science & Information Technology

You might also like to view...

You are integrating a bug reporting system with a configuration management tool to track bug reports, bug fixes, feature requests, and enhancements. You are considering an issue model for integrating these tools. Draw a class diagram of the issue model, the corresponding discussion, configuration management, and bug- reporting elements.

What will be an ideal response?

Computer Science & Information Technology

New document libraries contain several basic files that can be deleted if you choose not use them

Indicate whether the statement is true or false

Computer Science & Information Technology

Briefly explain the options in Microsoft Office 2016 that you can use if you do not know how to perform a task.?

What will be an ideal response?

Computer Science & Information Technology

Another name for the name and job title of the writer is

A) inserted signature text. B) complimentary close. C) writer's signature block. D) inside address.

Computer Science & Information Technology