Beginner programmers on reddit seem to really struggle with the concept of interfaces or pure virtual functions. I thought up a hillarious example to show them what it is all about. I give you, Yelvis.cpp
/* Abstract class Animal and a bunch of concrete implementing classes like Dog, Cat, and Bird goes here */Vector<Animal> animals = getZoo();
for(auto it = animals.begin(); it != animals.end(); it++) {
it->vocalize()
}/*
Prints the following:
"Dog goes woof
Cat goes meow
Bird goes tweet
Mouse goes squeekCow goes moo
...but there is one sound that no one knows...
Frog goes croak
Elephant goes toot
Ducks say quack
Fish go blub
Seal goes ow, ow, ow"
What does the generic Animal say?
*/