fork download
  1. #include <stdio.h>
  2.  
  3. class RtR {
  4. public:
  5. operator int() const
  6. {
  7. puts("operator int()");
  8. return 42;
  9. }
  10. operator double() const
  11. {
  12. puts("operator double()");
  13. return 3.14;
  14. }
  15. };
  16.  
  17. void f(int) {}
  18.  
  19. int main()
  20. {
  21. RtR x;
  22. int i = x; // or int i = RtR();
  23. double d = x;
  24. f(x);
  25. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
operator int()
operator double()
operator int()