Inheritance - Hirerichal and Hybrid
Inheritance - Hirerichal and Hybrid
Create a base class called "Animal" with a constructor that takes a name
as a parameter and an "eat()" method that displays "{name} is eating."
Create a derived class called "Pet" that inherits from "Animal" and has a
constructor taking a name as a parameter. It should also have a "play()"
method that displays "{name} is playing."
Create derived classes "Dog" and "Cat" that inherit from "Pet." Both
classes should have a constructor taking a name as a parameter. "Dog"
should have a "bark()" method displaying "{name} is barking!" and "Cat"
should have a "meow()" method displaying "{name} says meow!"
// Base class
class Animal {
public:
void displayType() {
};
// Derived class 1
public:
void displayType() {
};
// Derived class 2
void displayType() {
};
public:
void displayType() {
};
int main() {
Platypus platypus;
return 0;