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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.