Write a program which uses the concept of Single Inheritance
// C++ program to explain
// Single inheritance
#include <iostream>
using namespace std;
// base class
class Fruit {
public:
Fruit()
{
cout << "This is a Fruit" << endl;
}
};
// sub class derived from a single base classes
class Mango : public Fruit{
};
// main function
int main()
{
// creating object of sub class will
// invoke the constructor of base classes
Mango m1;
return 0;
}
Comments
Leave a comment