Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
using namespace std; class Point { int x; int y; public: Point() {} Point(int _x, int _y) { x = _x; y = _y; } void set_x(int _x) { x = _x; } void set_y(int _y) { y = _y; } int get_x() { return x; } int get_y() { return y; } Point operator + (Point tmp) { Point result(x + tmp.x, y + tmp.y); return result; } Point operator - (Point tmp) { Point result(x - tmp.x, y - tmp.y); return result; } Point operator * (Point tmp) { Point result(x * tmp.x, y * tmp.y); return result; } Point operator / (Point tmp) { Point result(x / tmp.x, y / tmp.y); return result; } }; int main() { Point p1(1, 2); Point p2(3, 4); Point p3 = p1 + p2; Point p4 = p1 - p2; Point p5 = p1 * p2; Point p6 = p1 / p2; cout << p3.get_x() << " " << p3.get_y() << endl; cout << p4.get_x() << " " << p4.get_y() << endl; cout << p5.get_x() << " " << p5.get_y() << endl; cout << p6.get_x() << " " << p6.get_y() << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)