0

why this output only comes 3 and why not output 123? #include<iostream> using namespace std; class A{ public: virtual void f(){cout<<1;} }; class B:public A{ public: void f(){cout<<2;} }; class C:public B{ public: void f(){cout<<3;} }; int main() { B *p=new C; p->f(); }

24th Aug 2016, 2:21 PM
Lekhraj Singh
Lekhraj Singh - avatar
3 Answers
0
thanks Nestor
26th Aug 2016, 4:15 AM
Lekhraj Singh
Lekhraj Singh - avatar
0
Nestor, what tag name I use to search for this question?
26th Aug 2016, 4:16 AM
Lekhraj Singh
Lekhraj Singh - avatar