Question

In C++, class D inherits from both class B and class C, and both B and C separately inherit from a common base class A (without using virtual inheritance). What problem does this classic "diamond inheritance" arrangement create, and how is it resolved?

A It creates two separate, ambiguous copies of class A's members within D, causing a compile-time ambiguity error when accessing A's members through D; this is resolved by declaring B and C's inheritance from A as "virtual," ensuring only one shared copy of A exists within D
B It creates a circular dependency that C++ automatically detects and prevents at compile time, requiring no further action from the programmer
C It causes a runtime-only error that can only be caught using try-catch exception handling around the object's constructor
D It automatically merges A's members into a single shared copy by default in standard C++, without requiring any special keyword
E It is resolved by declaring class D itself as virtual, rather than modifying the inheritance declarations of B and C
Practice Next

Hey! Ask a query

🎓
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
  • 200 Questions with Detailed Solutions
  • Section-wise Coverage (GA, English, Quant & Reasoning)