#include <iostream>

struct IAnimal {
    virtual void eat() = 0;
};

struct Dog: public IAnimal {
    void eat() {
        std::cout << "Dog eats\n";
    }
};

struct Cat: public IAnimal {
    void eat() {
        std::cout << "Cat eats\n";
    }
};

struct Owner {
    void feed(IAnimal* animal) {
        animal->eat();
    }
};

int main() {

    Dog dog;
    Cat cat;   
    Owner owner;
    owner.feed(&dog);
    owner.feed(&cat);
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: