fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Base {
  6. virtual void SomeMethod() {
  7. std::cout<<"Do Something"<<std::endl;
  8. }
  9. };
  10.  
  11. struct Der : public Base {
  12. virtual void SomeMethod() override = 0;
  13. };
  14.  
  15. struct DerDer : Der {
  16. virtual void SomeMethod() override
  17. {
  18. std::cout<<"Do something derived."<<std::endl;
  19. }
  20. };
  21.  
  22. int main(int argc, char *argv[])
  23. {
  24. DerDer x;
  25. Base *pX = &x;
  26. pX->SomeMethod();
  27. return 0;
  28. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Do something derived.