Last active
December 14, 2016 23:41
-
-
Save ALSchwalm/648158e4ed019cdd40632fc9335b4994 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
struct Mammal { | |
Mammal() { std::cout << "Mammal::Mammal\n"; } | |
virtual ~Mammal() { std::cout << "Mammal::~Mammal\n"; }; | |
virtual void run() = 0; | |
virtual void walk() = 0; | |
virtual void move() { walk(); } | |
}; | |
struct Cat : Mammal { | |
Cat() { std::cout << "Cat::Cat\n"; } | |
virtual ~Cat() { std::cout << "Cat::~Cat\n"; } | |
virtual void run() { std::cout << "Cat::run\n"; } | |
virtual void walk() { std::cout << "Cat::walk\n"; } | |
}; | |
struct Dog : Mammal { | |
Dog() { std::cout << "Dog::Dog\n"; } | |
virtual ~Dog() { std::cout << "Dog::~Dog\n"; } | |
virtual void run() { std::cout << "Dog::run\n"; } | |
virtual void walk() { std::cout << "Dog::walk\n"; } | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment