Abstract Classes
Abstract Classes
- Used to generalize the characteristics of a hierarchy
- Defines the basic set of member data and methods(messages)
- Declares virtual functions that each derived class will
support
- Are not intended to have objects instantiated
- Define partial or incomplete “objects”
- Data or methods may not be sufficient for use in a real
object
- Provide the essential features for real objects of a hierarchy
- Identifies minimum data and methods that the class family
will contain
- Useful as program design tool
Pure Virtual Methods
- Special virtual methods
- Forces a class to be abstract class (partial class)
- Compiler won’t let objects of the class be
instantiated
- Syntax - declare a virtual method with an assignment
value
- class figure { …
virtual int draw ( ) = 0;
// assign 0 to
function name ( no body) };
- Can have a definition that provides a default function
body for derived class objects