0
What is the output of the following C++ program?
#include <iostream>
using namespace std;
class B {
public:
virtual void f(int x = 1) { cout << "B" << x; }
};
class D : public B {
public:
void f(int x = 2) { cout << "D" << x; }
};
int main() {
B* p = new D();
p->f();
return 0;
}- AD1
- BD2
- CB1
- DB2
Correct answer: A