fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class A{
  5. public:
  6. void fun(){
  7. cout<<"base ";
  8. }
  9. };
  10. class B: public A{
  11. public:
  12. void fun(){
  13. cout<<"derived ";
  14. }
  15. };
  16. int main(){
  17. A *a=new B;
  18. a->fun();
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
base