fork download
  1. #include <iostream>
  2.  
  3. class Foo
  4. {
  5. public:
  6. Foo() : x(0) {}
  7. operator int () { return x; }
  8. private:
  9. int x;
  10. };
  11.  
  12. void testFoo(Foo& foo)
  13. {
  14. std::cout << "In testFoo(Foo& foo)\n";
  15. }
  16.  
  17. void testFoo(int x)
  18. {
  19. std::cout << "In testFoo(int x)\n";
  20. }
  21.  
  22. int main()
  23. {
  24. Foo f;
  25. testFoo(f);
  26. testFoo((int)f);
  27. }
  28.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
In testFoo(Foo& foo)
In testFoo(int x)