Skip to content

Instantly share code, notes, and snippets.

@jesyspa
Created June 24, 2012 19:25
Show Gist options
  • Save jesyspa/2984602 to your computer and use it in GitHub Desktop.
Save jesyspa/2984602 to your computer and use it in GitHub Desktop.
Example of bad implementation of a 1D point class
class PointBad {
private:
int x_;
public:
PointBad(int x) : x_(x) {}
int GetX() {
return this->x_;
}
};
void f() {
PointBad const p(5);
std::cout << p.GetX(); // Compiler error: calling member function on const instance
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment