Answer to Question #264103 in C++ for abc

Question #264103

Write a programme in c++ to Overload << operator using friend function.


1
Expert's answer
2021-11-10T11:53:15-0500
#include<iostream>
using namespace std;
class Overload{
	public:
		int x, y;
	friend ostream &operator<<(ostream &output, const Overload &D);
};
ostream &operator<<(ostream &output, const Overload &D){
	output<<"X is: "<<D.x<<"Y is: "<<D.y<<endl;
}
int main(){
	Overload O;
	O.x = 6;
	O.y = 9;
	cout<<O<<endl;
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS