Answer to Question #201683 in C++ for Asif

Question #201683

Write a program which uses the concept of Single Inheritance


1
Expert's answer
2021-06-01T07:44:18-0400
#include <iostream>

class Base
{
  public:

    virtual void Func()
    {
        std::cout << "func from base class\n";
    }

    virtual ~Base()
    {
    }
};

class Derived : public Base
{
  public:

    virtual void Func()
    {
        std::cout << "func from derived class\n";
    }
};

int main()
{
    Base* base = new Base;
    Base* derived = new Derived;

    base->Func();
    derived->Func();

    delete base;
    delete derived;
    
    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