+ 1
Overriding
If a base class and derived class each include a member function with the same name, which member function will be called by an object of a derived class and why.
2 Answers
+ 3
Depends on the object... If object of parent class is used... The method in parent (base class) is invoked else the other
Try this...
I know It's in JAVA... But well Explained..
https://www.geeksforgeeks.org/overriding-in-java/
+ 1
It depends on the type of object. Whether the object is of parent class type or derived class type.
For eg: ParentA is a parent class and ChildB is its subclass and they both have a method called walk().
Now,
ParentA obj = new ParentA();
obj.walk();
/*will call the walk() defined in parent class*/
ChildB obj2 = new ChildB();
obj2.walk();
/*will call the walk() defined in child class*/
So the object of a derived class call the method defined in derived class.
Note: defined according to my knowledge in java.