MCQs > IT & Programming > C++ > Output of the following code? #include using namespace std; class b { int i; public: void vfoo() { cout <<'In Base '; } }; class d : public b { int j; public: void vfoo() { cout<<'In Derived '; } }; void main() { b *p, ob; d ob2; p = &ob; p->vfoo(); p = &ob2; p->vfoo(); ob2.vfoo(); }

C++ MCQs

What will be the output of the following code?

 #include<iostream>
 using namespace std;
 class b
 {
 int i;
 public:
 void vfoo()
 { cout <<"In Base "; }
 };
 class d : public b
 {
 int j;
 public:
 void vfoo()
 {
 cout<<"In Derived ";
 }
 };
 void main()
 {
 b *p, ob;
 d ob2;
 p = &ob;
 p->vfoo();
 p = &ob2;
 p->vfoo();
 ob2.vfoo();
 }

Answer

Correct Answer: In Base In Base In Derived

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it