A class with at least one pure virtual function. Cannot be instantiated directly.
class AForm {
virtual void execute() = 0; // Pure virtual function
};- Declared using
= 0syntax - Must be implemented by derived classes
- Makes class abstract
- Defines interface for derived classes
virtual ~AForm(); // Required for proper cleanup of inheritance hierarchiesAForm (Abstract Base)
├── ShrubberyCreationForm
├── RobotomyRequestForm
└── PresidentialPardonForm
Each concrete form has:
- Specific grade requirements
- Unique execution behavior
- Name and target handling
- Input validation
- Exception handling
-
ShrubberyCreationForm:
- Creates ASCII tree file
- Grades: Sign 145, Execute 137
- File I/O operations
-
RobotomyRequestForm:
- 50% success rate
- Drilling noises
- Grades: Sign 72, Execute 45
-
PresidentialPardonForm:
- Simplest execution
- Highest grade requirements
- Grades: Sign 25, Execute 5