Advertisement
Josif_tepe

Untitled

Nov 21st, 2021
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. class BaseClass {
  5. public:
  6.     BaseClass() {}
  7.    
  8.     virtual void print() {
  9.         cout << "base class" << endl;
  10.     }
  11.    
  12. };
  13. class DerivedClass : public BaseClass {
  14. public:
  15.     DerivedClass(){}
  16.     void print()
  17.     { cout << "derived class" << endl;
  18.     }
  19. };
  20. int main(){
  21.     BaseClass *b = new DerivedClass();
  22.    
  23.     b->print();
  24.    
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement