From 14610f90633c8747d4ac278e739203890e64447b Mon Sep 17 00:00:00 2001 From: Aleksandra771 <71434163+Aleksandra771@users.noreply.github.com> Date: Wed, 30 Dec 2020 10:00:34 +0300 Subject: [PATCH] kulikovaexam --- kulikova.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 kulikova.cpp diff --git a/kulikova.cpp b/kulikova.cpp new file mode 100644 index 0000000..1ca565d --- /dev/null +++ b/kulikova.cpp @@ -0,0 +1,44 @@ +#include +#include +using namespace std; +class Animal { +public: + Animal(string l, string b) { + location = l; + boundaries = b; + } + virtual void display() { + cout << "animal " << location << " " << boundaries << endl; + } + void sleep() { + cout << "animal sleep" << endl; + } +protected: + string location; + string boundaries; +}; +class Lion : public Animal { +public: + Lion(string location, string boundaries) : Animal(location, boundaries) {}; + void display() override + { + cout << "Lion is located in " << location << ", expecially in the " << boundaries << " Desert." << endl; + } +}; +class Cat : public Animal { +public: + Cat(string location, string boundaries) : Animal(location, boundaries) {}; + void display() override + { + cout << "Cat is located in " << location << ", namely in the " << boundaries << " region." << endl; + } +}; + +int main() { + Lion leva("Africa", "Sahara"); + Cat Myrzik("Russia", "Ivanovo"); + + Myrzik.display(); + leva.display(); + return 0; +} \ No newline at end of file