I'm currently learning Object Oriented Programming and I came with this doubt:
Let's say I have an abstract class Animal. To simplify, it will have only one virtual method, talk:
class Animal {
public:
    virtual string talk() = 0;
}
And the classes Cat and Dog, both derived from the abstract class Animal:
class Cat : public Animal {
public:
    string talk(){
        return "Meow";
    }
}
class Dog : public Animal {
public:
    string talk(){
        return "Woof";
    }
}
I want to create the class Pet, which receives a Dog or a Cat as argument:
class Pet {
public:
    Pet(Animal myPet){
    this->myPet = myPet;
    }
    Animal myPet;
}
However, I cannot do this, since "Animal" is an abstract class. How can I solve this problem?
 
     
     
    