Skip to content

Instantly share code, notes, and snippets.

@ChrisVilches
Created May 31, 2022 20:33
Show Gist options
  • Save ChrisVilches/2734de57b3bfb30e3e262e66935d02af to your computer and use it in GitHub Desktop.
Save ChrisVilches/2734de57b3bfb30e3e262e66935d02af to your computer and use it in GitHub Desktop.
How to print and read custom data in C++.
#include <bits/stdc++.h>
using namespace std;
struct Point {
int x, y;
};
ostream& operator<<(ostream& os, const Point& p) {
return os << "(" << p.x << ", " << p.y << ")";
}
istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }
int main() {
Point a, b;
cin >> a >> b;
cout << a << endl;
cout << b << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment