fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Cls {
  6. public:
  7. Cls(bool value, const char *msg) :
  8. m_value(value),
  9. m_name(msg)
  10. {
  11. cout << "Cls::Cls(" << m_name << ")" << endl;
  12. }
  13.  
  14. Cls& operator &&(const Cls &other) {
  15. cout << "Cls(" << m_name << ")::operator &&(" << other.m_name << ")" << endl;
  16. return *this;
  17. }
  18.  
  19. operator bool() const {
  20. cout << "Cls(" << m_name << ")::operator bool()" << endl;
  21. return m_value;
  22. }
  23.  
  24. private:
  25. bool m_value;
  26. string m_name;
  27. };
  28.  
  29. class T : public Cls {
  30. public:
  31. T(const char *msg) : Cls(true, msg) {}
  32. };
  33.  
  34. class F : public Cls {
  35. public:
  36. F(const char *msg) : Cls(false, msg) {}
  37. };
  38.  
  39. int main() {
  40. cout << "Mission:" << endl;
  41. if (F("a") && T("b") && T("c")) {
  42. cout << "... completed" << endl;
  43. } else {
  44. cout << "... failed" << endl;
  45. }
  46.  
  47. return 0;
  48. }
  49.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Mission:
Cls::Cls(c)
Cls::Cls(b)
Cls::Cls(a)
Cls(a)::operator &&(b)
Cls(a)::operator &&(c)
Cls(a)::operator bool()
... failed