Skip to content

Instantly share code, notes, and snippets.

@javedbaloch4
Last active June 20, 2020 18:45
Show Gist options
  • Save javedbaloch4/16e53fe5eb8a059eff2e65ab845d64c7 to your computer and use it in GitHub Desktop.
Save javedbaloch4/16e53fe5eb8a059eff2e65ab845d64c7 to your computer and use it in GitHub Desktop.
In general OOP diamond problem solution writing in C++.
// 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