Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following class definition (Pair.hpp), Implement the output stream ope

ID: 3856694 • Letter: G

Question

Given the following class definition (Pair.hpp), Implement the output stream operator that should be in the Pair.cpp:

#ifndef _PAIR_HPP_

#define _PAIR_HPP_

#include <iostream>

#include <cstdlib>

using namespace std;

class Pair {

    public:

        Pair();

        Pair(int n1, int n2);

        Pair(const Pair& orig);

        ~Pair();

  Pair& operator=(const Pair&other);            

        friend ostream& operator<<(ostream&strm, const Pair &p);

    private:

        int x, y;

    }; C

}

#endif

Explanation / Answer

PROGRAM CODE:

pair.cpp

#include <iostream>

#include "Pair.hpp"

using namespace std;

ostream& operator<<(ostream&strm, const Pair &p)

{
strm<<p.x<<" "<<p.y<<" ";

return strm;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote