I have a class Child, inheriting from class Parent. Class Parent has a virtual protected method _parentClassMethod(int a, int b). This method is used in a method of class Child:
void Child::_childClassMethod(int c, int d)
{
//some code
_parentClassMethod(int a, int b);
//some more code
}
My problem is: in _parentClassMethod, there is a function call I need to do differently when called from Child class. I am blanking out but is there a better way to do it other than redefining the entire _parentClassMethod in Child class?
Definition of the parentClassMethod:
void Parent::_parentClassMethod(int a, int b){
//lots of other code
setSomethingFunction(val1, val2, val3);/*this function cannot be made virtual since it writes to the eeprom of a device*/
//lot more code
}
Define a virtual function in parent and override (thanks @k-ballo) it in the child class.