1
Loading subject content…
Loading subject content…
Loading practice questions…
What will be the output of the program?
#include <iostream>
using namespace std;
class A { public: int n = 10; };
class B : virtual public A {};
class C : virtual public A {};
class D : public B, public C {};
int main() {
D d;
d.n = 5;
cout << d.B::n + d.C::n << endl;
return 0;
}What will be the output of the program?
#include <iostream>
using namespace std;
class A { public: int x = 1; };
class B : public A { public: int y = 2; };
int main() {
B b;
cout << b.x + b.y << endl;
return 0;
}