Last active
June 20, 2020 18:45
-
-
Save javedbaloch4/16e53fe5eb8a059eff2e65ab845d64c7 to your computer and use it in GitHub Desktop.
In general OOP diamond problem solution writing in C++.
This file contains hidden or 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
| // Written by Javed Ahmed - F2019266402 | |
| #include <iostream> | |
| using namespace std; | |
| class Animal { | |
| public: | |
| void eat() { | |
| cout << "Animal is eating.\n"; | |
| } | |
| }; | |
| class Mamal: public virtual Animal { | |
| public: | |
| void breath() { | |
| cout << "Mamal is breath. \n"; | |
| } | |
| }; | |
| class WingedAnimal : public virtual Animal { | |
| public: | |
| void fly() { | |
| cout << "Winged Animal can fly."; | |
| } | |
| }; | |
| class Bat : public Mamal, public WingedAnimal { | |
| }; | |
| int main() | |
| { | |
| Bat b; | |
| b.eat(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment