Skip to content

Instantly share code, notes, and snippets.

@Petesta
Last active August 29, 2015 14:14
Show Gist options
  • Save Petesta/ac39b5d145ea4f781101 to your computer and use it in GitHub Desktop.
Save Petesta/ac39b5d145ea4f781101 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class Point {
public:
int _x;
int _y;
Point(int x, int y) : _x(x), _y(y) {}
int& x() { return this->_x; }
int& y() { return this->_y; }
};
int main() {
Point p(1, 2);
cout << p.x() << endl;
p.x() += 1;
cout << p.x() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment