0
What is Shadowing in C++?
Class A { public: void f1() cout<<"base f1"; }; Class B:public A { public: void f1() cout<<"derived f1"; }; int main() { B b; b.f1(); } In above if i create object of derived class and call f1 method then it give call to base class f1 and not derived f1. But as per shadowing concept in C++ , if method name in base and derived is same and we are calling that method using derived class object then it will hide the base class method implementation and call derived class method. But why in this scenario it is giving me base class method?
3 Réponses
0
~ swim ~ updated question please have a look