fork download
  1. #include <iostream>
  2.  
  3. class Foo {
  4. public:
  5. explicit Foo(bool v);
  6.  
  7. bool operator &&( const Foo& other ) const;
  8.  
  9. private:
  10. bool v;
  11. };
  12.  
  13. Foo::Foo(bool v) : v(v) {
  14. std::cout << "constructed with " << v << std::endl;
  15. }
  16.  
  17. bool Foo::operator &&(const Foo& other) const {
  18. std::cout << "called && " << std::endl;
  19. return v && other.v;
  20. }
  21.  
  22. int main() {
  23. if (Foo(false) && Foo(true));
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
constructed with 1
constructed with 0
called &&