Question: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();
}
 

A In Base In Base In Derived 

B In Base In Derived In Derived 

C In Derived In Derived In Derived 

D In Derived In Base In Derived 

E In Base In Base In Base 

+ Answer
+ Report
Total Preview: 632

Copyright © 2024. Powered by Intellect Software Ltd