Skip to content

Instantly share code, notes, and snippets.

@ALSchwalm
Last active December 14, 2016 23:41
Show Gist options
  • Save ALSchwalm/648158e4ed019cdd40632fc9335b4994 to your computer and use it in GitHub Desktop.
Save ALSchwalm/648158e4ed019cdd40632fc9335b4994 to your computer and use it in GitHub Desktop.
#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