0
What is the output of the following C++ program?
#include <iostream>
using namespace std;
class B { public: virtual void f() { cout << "B"; } };
class D : public B { public: void f() { cout << "D"; } };
void g(B b) { b.f(); }
int main() {
D d; g(d);
B &r = d; r.f();
B *p = &d; p->f();
}- ABDD
- BDDD
- CBBB
- DBBD
Correct answer: A