fork download
  1. class A { public: int x; A(int xx) { x = xx; } operator int() {return x;}};
  2. class B { public: int x; B(int xx) { x = xx; } operator int() {return x;}};
  3.  
  4. A f(A a) { return a+a; }; // this is ugly and I'd want to be able to use: return a+a
  5.  
  6. int main()
  7. {
  8. A a = 5;
  9. //B b = 5;
  10. f(a); // This will work...
  11. //f(b); // This won't compile...
  12. }
Success #stdin #stdout 0s 2736KB
stdin
Standard input is empty
stdout
Standard output is empty