Answer to Question #201573 in C++ for Asif

Question #201573

Write a program which uses the concept of Single Inheritance


1
Expert's answer
2021-06-01T15:00:42-0400
// 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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog