Skip to content

Instantly share code, notes, and snippets.

@jesyspa
Created June 24, 2012 19:27
Show Gist options
  • Save jesyspa/2984611 to your computer and use it in GitHub Desktop.
Save jesyspa/2984611 to your computer and use it in GitHub Desktop.
Another broken 1D point implementation
struct PointAgainBroken {
private:
int x_;
void SetXToSeven() {
this->x_ = 7;
}
public:
PointAgainBroken(int x) : x_(x) {}
int GetX() const {
this->SetXToSeven(); // Compiler error: not allowed to call non-const member function on this.
return this->x_;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment