Skip to content

Instantly share code, notes, and snippets.

@false-git
Last active March 9, 2019 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save false-git/e86a9ea25f50f5157a4e493d0e597a36 to your computer and use it in GitHub Desktop.
Save false-git/e86a9ea25f50f5157a4e493d0e597a36 to your computer and use it in GitHub Desktop.
#include <iostream>
class I {
private:
int value;
public:
I(int i): value(i) {}
I operator+(int i) const {
return I(value - i);
}
operator int() const {
return value;
}
};
int main(int argc, char *argv[]) {
I i(2);
std::cout << i << "+" << 3 << "=" << i + 3 << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment