fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A{
  5. public:
  6. virtual void p() = 0;
  7. };
  8.  
  9. class B: public A{
  10. public:
  11. virtual void p() override {
  12. cout << "abc:" << m << endl;
  13. };
  14. int m;
  15. };
  16.  
  17. void cb(void* x){
  18. A* a = reinterpret_cast<A*>(x);
  19. a->p();
  20. }
  21.  
  22. int main() {
  23. B b;
  24. b.m = 10;
  25.  
  26. cb(&b);
  27. // your code goes here
  28. return 0;
  29. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
abc:10