Difficulty: Easy
Correct Answer: Correct — derivation needs the interface/type, not necessarily the full source.
Explanation:
Introduction / Context:
Reuse through inheritance often targets library types. In both C++ and C#, you can derive from classes defined in precompiled libraries as long as the compiler and linker (or runtime) can see the necessary interface/type information. Source code access is not required for inheritance to function.
Given Data / Assumptions:
Concept / Approach:
Compilers need type declarations (signatures, visibility, vtable layout in C++ per ABI) to compile derived classes. Linkers/CLR/JIT resolve definitions at build/run time. If the base class permits derivation (not final
in C++ or sealed
in C#), and the constructor/protected interface is accessible, you can derive without the source. This is standard practice when extending frameworks and SDKs.
Step-by-Step Solution:
Verification / Alternative check:
Many UI frameworks (MFC, .NET WinForms/WPF) and game engines encourage subclassing library classes without supplying their source code to developers.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing the availability of symbol definitions at link/runtime with the need for source code; or forgetting sealed/final restrictions that can disallow derivation even if the type is visible.
Final Answer:
Correct — derivation needs the interface/type, not necessarily the full source.
Discussion & Comments