why this output 1 and why not 2? class A{ void f(){cout<<1;} }; class B: public A{ private: void f(){cout<<2;} }; void g(A &a){a.f()} int main(){ B b; g (b); } | SoloLearn: Learn to code for FREE!

0

why this output 1 and why not 2? class A{ void f(){cout<<1;} }; class B: public A{ private: void f(){cout<<2;} }; void g(A &a){a.f()} int main(){ B b; g (b); }

c++

8/25/2016 11:25:31 AM

Lekhraj Singh

1 Answer

New Answer

+1

Because the function g take a class called A in parameter. So he will call the f() function from A