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();
return 0;
}- ABB
- BDD
- CBD
- DDB
Correct answer: C