Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class IJumpable
- {
- public:
- virtual void jump() = 0;
- };
- void IJumpable::jump()
- {
- std::cout << "Jumper bumper ";
- }
- class IFlyable
- {
- public:
- virtual void fly() = 0;
- };
- void IFlyable::fly()
- {
- std::cout << "I belive I can Flyyy ";
- }
- class JumpingParrot : public IJumpable, public IFlyable
- {
- public:
- void jump() override { std::cout << "Jumping parrot jump-jump...\n"; }
- void fly() override { IFlyable::fly(); std::cout << " I'm a jumping Parrrot!\n"; }
- };
- class Frog : public IJumpable
- {
- public:
- void jump() override { std::cout << "Froggy jump-jump! Kwaaaa!\n"; }
- };
- class Bird : public IFlyable
- {
- public:
- void fly() override { std::cout << "Ein kleine Nachtigal! Zehr gut!\n"; }
- };
- int main()
- {
- IFlyable* flyers[]{ new Bird{}, new JumpingParrot{} };
- IJumpable* jumpers[]{ new JumpingParrot{}, new Frog{} };
- for (const auto& flyer : flyers) { flyer->fly(); }
- for (const auto& jumper : jumpers) { jumper->jump(); }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement