Use Base keyword to call method in parent class from subclass : Base Class « Class « C++






Use Base keyword to call method in parent class from subclass

  
#include <iostream>
using namespace std;
class Base {
 public:
   void display(void) { cout << "This is the base class" << endl; };
};

class Derived: public Base {
 public:
   void display(void) { cout << "This is the derived class" << endl; };
};

int main(void){
   Derived my_class;

   my_class.display();
   my_class.Base::display();
}
  
    
  








Related examples in the same category

1.Base class and derived classBase class and derived class
2.Using base pointers on DerivedClass class objects.Using base pointers on DerivedClass class objects.
3.Pass arguments to base classPass arguments to base class
4.Init member variables from base classInit member variables from base class
5.class to represent a book