fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class C {
  5. private:
  6. int * p;
  7. public:
  8. C() : p(0) {}
  9. operator bool() const {cout << "bool() const\n"; return p != 0;}
  10. //operator bool() {cout << "bool()\n"; return p != 0;}
  11. operator int*() const {cout << "int*() const\n"; return p;}
  12. operator int**() {cout << "int**()\n"; return &p;}
  13. };
  14.  
  15. void test() {
  16. C c;
  17. bool b = c;
  18. int* p = c;
  19. int** pp = c;
  20. }
  21.  
  22. int main() {
  23. test();
  24. return 0;
  25. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
int**()
int*() const
int**()