Last active
August 29, 2015 14:14
-
-
Save Petesta/ac39b5d145ea4f781101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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