Created
April 22, 2019 15:54
-
-
Save keddad/e54e1675bcacf1b4f17abacacb656def 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 <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