MCQs > IT & Programming > C++ > Output of the following code? class b { int i; public: virtual void vfoo() { cout <<'Base '; } }; class d1 : public b { int j; public: void vfoo() { j++; cout <<'Derived'; } }; class d2 : public d1 { int k; }; void main() { b *p, ob; d2 ob2; p = &ob; p->vfoo(); p = &ob2; p->vfoo(); }

C++ MCQs

What will be the output of the following code?
class b
{
int i;
public:
virtual void vfoo()
{
cout <<"Base ";
}
};
class d1 : public b
{
int j;
public:
void vfoo()
{
j++;
cout <<"Derived";
}
};
class d2 : public d1
{
int k;
};
void main()
{
b *p, ob;
d2 ob2;
p = &ob;
p->vfoo();
p = &ob2;
p->vfoo();
}

Answer

Correct Answer: Base 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