fork download
  1. #include <iostream>
  2.  
  3. class Foo {
  4. public:
  5. operator void* () {
  6. std::cout << "Boom!\n";
  7. return ptr;
  8. }
  9.  
  10. private:
  11. void *ptr;
  12. };
  13.  
  14. int main()
  15. {
  16. Foo f;
  17. void* pf = (void*)f;
  18. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Boom!