286
GB
What is the output: class A{public: virtual void f(){cout<<'A';}}; class B:public A{public: void f() override{cout<<'B';}}; A &r=*new B; r.f();
IN
आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
A
ए
B
B
बी
C
AB
अब
D
Compile error
संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English)
r is reference to A but bound to B. Virtual dispatch calls B::f(). Output: B.
व्याख्या (हिन्दी)
r, A का संदर्भ है लेकिन B से जुड़ा है। वर्चुअल प्रेषण कॉल B::f() है। आउटपुट: बी.