fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. public:
  6. A( int a ) : a(a) { }
  7. A operator&&( const A& a )
  8. {
  9. std::cout << "operator &&" << std::endl;
  10. return *this;
  11. }
  12.  
  13. operator bool()
  14. {
  15. std::cout << "operator bool : " << a << std::endl;
  16. return false;
  17. }
  18.  
  19. A& operator()()
  20. {
  21. std::cout << "operator () : " << a << std::endl;
  22. return *this;
  23. }
  24. private:
  25. const int a;
  26. };
  27.  
  28. int main() {
  29.  
  30. A a1(1), a2(2), a3(3);
  31.  
  32. if( a1() && a2() && a3() )
  33. {
  34.  
  35. }
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
operator () : 3
operator () : 2
operator () : 1
operator &&
operator &&
operator bool : 1