fork download
  1. #include<iostream>
  2.  
  3. using namespace std;
  4. class Base{
  5. public:
  6. virtual void display(){
  7. cout<<"Base"<<endl;
  8.  
  9. }
  10. };
  11. class Derived:public Base{
  12. public:
  13. void display() override{
  14. cout<<"Derived"<<endl;
  15.  
  16. }
  17. };
  18. int main(){
  19. Base*b=new Derived();
  20. b->display();
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Derived