Skip to main content

Posts

Showing posts with the label implementation multilevel inheritance.

what is abstract class? Write a program in C++ that implements the concept of multilevel inheritance.

An abstract class is a class that cannot be instantiated on its own, but instead is meant to be used as a base class for other classes. An abstract class contains at least one pure virtual functions, which is a virtual function that has no implementation in the base class and is meant to be overridden by derived classes. Now, let's write a program in C++ that implements the concept of multilevel inheritance, which is a type of inheritance where a derived class is created from another derived class. #include <iostream> using namespace std; class Animal {     public:         void eat() {             cout << "Animal is eating." << endl;         } }; class Dog : public Animal {     public:         void bark() {             cout << "Dog is barking." << endl;         } }; class GermanShepherd : public Dog ...