Enums can define abstract methods, which each enum member is required to implement.
enum Action {
DODGE {
public boolean execute(Player player) {
return player.isAttacking();
}
},
ATTACK {
public boolean execute(Player player) {
re...
Abstract base classes (ABCs) enforce what derived classes implement particular methods from the base class.
To understand how this works and why we should use it, let's take a look at an example that Van Rossum would enjoy. Let's say we have a Base class "MontyPython" with two methods (jo...
Abstract Method
declared without an implementation
C++
pure virtual method
virtual void eat(void) = 0;
Java
abstract method
abstract void draw();
Abstract Class
cannot be instantiated
C++
cannot be instantiated; has at least 1 pure virtual method
class AB {public: virtual void f() = ...