fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Damage
  5. {
  6. public:
  7. // ...
  8. operator int ()
  9. {
  10. return this->GetDamage();
  11. }
  12.  
  13. int GetDamage()
  14. {
  15. return 3;
  16. }
  17. };
  18.  
  19. int main() {
  20. Damage d;
  21. int health = 4;
  22.  
  23. std::cout << health - d << std::endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1