mercredi 24 mai 2017

override specfifc base class function in derive

#include <iostream>
using namespace std;

class A
{
    public:
    virtual void hello() { cout << "Base A" << endl; }
};

class B
{
    public:
    virtual int hello() { cout << "Base B" << endl; }
};

class AB:public A,public B
{
    public:

    void hello() override { cout << "derive" << endl; }
};

int main() {
    // your code goes here

    return 0;
}

The above code results in error with conflicting return type for hello , but I am only interested to override function of Class A , is there any way to achieve that?

Aucun commentaire:

Enregistrer un commentaire