Abstract Classes
abstract class defines abstract classes, which can declare methods without implementations (abstract methods). Abstract classes themselves cannot be instantiated—they are incomplete templates that must be completed by subclasses. Subclasses must implement all abstract methods, otherwise they must also be declared as abstract classes.
Abstract methods are declared with func but provide no function body. Abstract classes can also contain concrete methods (with function bodies), and these concrete methods can call abstract methods—runtime will dispatch to the subclass implementation. This design pattern is commonly used to define algorithm frameworks (template method pattern).
The Shape below is an abstract class that declares two abstract methods: area() and label(). Concrete Circle and Rectangle must implement them. The abstract class's describe() method calls these abstract methods, forming a template method.
Attempting to create an instance with Shape() will result in a compilation error—abstract classes cannot be instantiated.
Try writing Shape() in main() and observe the compilation error message.