fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Ptr {
  5. public:
  6. Ptr( int * p ) : m_ptr( p ) {}
  7. operator bool() const {
  8. std::cout << "bool" << std::endl;
  9. return m_ptr != 0;
  10. }
  11. explicit operator int*() {
  12. std::cout << "pointer" << std::endl;
  13. return m_ptr;
  14. }
  15. private:
  16. int * m_ptr;
  17. };
  18.  
  19.  
  20. int main() {
  21.  
  22. Ptr p( 0 );
  23. if ( p ) {
  24. int * t = static_cast<int*>(p);
  25. }
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
bool