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