fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class my_bool {
  5. private:
  6. bool value;
  7. public:
  8. my_bool(bool value) : value(value) {}
  9. operator bool() { return value; }
  10.  
  11. friend my_bool operator==(const my_bool & instance_1, my_bool & instance_2);
  12. };
  13.  
  14. my_bool operator==(const my_bool & instance_1, my_bool & instance_2)
  15. {
  16. return instance_1 == instance_2;
  17. }
  18.  
  19. int main()
  20. {
  21. my_bool a = true;
  22. bool b = true;
  23. bool c = false;
  24.  
  25. if (a == b)
  26. cout << "a==b: true" << endl;
  27. else
  28. cout << "a==b: false " << endl;
  29.  
  30. if (a == c)
  31. cout << "a==c: true" << endl;
  32. else
  33. cout << "a==c: false " << endl;
  34.  
  35. if (a)
  36. cout << "a is: true" << endl;
  37. else
  38. cout << "a is: false " << endl;
  39. }
  40.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
a==b: true
a==c: false 
a is: true