Skip to content

Instantly share code, notes, and snippets.

@keddad
Created April 22, 2019 15:54
Show Gist options
  • Save keddad/e54e1675bcacf1b4f17abacacb656def to your computer and use it in GitHub Desktop.
Save keddad/e54e1675bcacf1b4f17abacacb656def to your computer and use it in GitHub Desktop.
#include <iostream>
struct Animal
{
virtual void Voice() = 0;
/*{
std::cout << "Oleg kruto!\n";
}*/
};
struct Dog : Animal
{
void Voice() override
{
std::cout << "Wav!\n";
}
};
struct Cat : Animal
{
void Voice() override
{
std::cout << "Meow!\n";
}
};
struct Parrot : Animal
{
/*void Voice()
{
std::cout << "Popka durak!\n";
}*/
};
int main()
{
Cat cat;
Dog dog;
Parrot parrot;
Animal& a1 = cat, &a2 = dog, &a3 = parrot;
a1.Voice();
a2.Voice();
a3.Voice();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment