English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In this article, you will learn about function overriding. In addition, you will also learn how to use C ++Evaluating the function overrides of the base class in programming.
InheritanceSoftware developers are allowed to derive new classes from existing classes. Derived classes inherit the functionality of the base class (existing class).
Assuming that both the base class and the derived class have a member function with the same name and parameters (the number and type of parameters).
If an object of the derived class is created and a member function that exists in both classes (base class and derived class) is called, the member function of the derived class will be called, ignoring the function of the base class.
C ++This feature is called function overriding.
To access the overridden function of the base class from the derived class, please use the scope resolution operator ::. For example,
If you want to access the getData() function of the base class, you can use the following statement in the derived class.
Base::getData();