CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Created by Kabilan K
#include<iostream>
using namespace std;
//create a Point class
class Point {
private:
int x, y;
public:
Point (int r = 0 , int i = 0 )
: x(r) , y(i) {}
Point& operator<< (const Point& c) {
cout << x+c.x << "," << y+c.y << endl;
return *this;
}
friend Point& operator<<(ostream& os, Point& c);
};
Point& operator<< (ostream& os, Point& c){
cout << c.x << "," << c.y << endl;
return c;
}
int main(){
Point c1 (2,5), c2(4, 6) ;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run