Difficulty: Easy
Correct Answer: Zero
Explanation:
Introduction / Context:
An abstract class is a class with at least one pure virtual function (declared with = 0). It represents an incomplete interface or behavior that must be provided by derived classes. Understanding instantiation rules for abstract classes is crucial in polymorphic design and interface-based programming.
Given Data / Assumptions:
Concept / Approach:
C++ forbids creating objects directly from an abstract class because it lacks complete behavior. However, you can create instances of derived classes that override all pure virtual functions. Polymorphic use is then achieved by referring to the concrete object through a pointer or reference to the abstract base.
Step-by-Step Solution:
Verification / Alternative check:
Compile-time diagnostics clearly state that you cannot instantiate an abstract type. After implementing all pure virtuals in the derived class, instantiation succeeds, confirming the rule.
Why Other Options Are Wrong:
One/Two/As many as we want: contradict the definition—no direct instances of abstract classes are allowed.
Common Pitfalls:
Final Answer:
Zero
Discussion & Comments