If base class and derived class have member functions with same name
and arguments. If you create an object of derived class and write code
to access that member function then, the member function in derived
class is only invoked, i.e., the member function of derived class
overrides the member function of base class. This feature in C++
programming is known as function overriding.
Accessing the Overridden Function in Base Class From Derived Class
To access the overridden function of base class from derived class, scope resolution operator ::. For example: If you want to accessget_data()
function of base class from derived class in above example then, the following statement is used in derived class.A::get_data; // Calling get_data() of class A.It is because, if the name of class is not specified, the compiler thinks
get_data()
function is calling itself.
Show Konversi KodeHide Konversi Kode Show EmoticonHide Emoticon