Last active
April 19, 2019 22:45
-
-
Save chichunchen/259f9fbed52f00de5acd406f31f88205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Base { | |
public: | |
// user wants to override this in | |
// the derived class | |
virtual void func() | |
{ | |
cout << "I am in base" << endl; | |
} | |
}; | |
// override.cpp:20:22: error: non-virtual member function marked 'override' hides virtual member function | |
// void func(int a) override | |
^ | |
// override.cpp:9:18: note: hidden overloaded virtual function 'Base::func' declared here: different number of parameters (0 vs 1) | |
// virtual void func() | |
class derived : public Base { | |
public: | |
// did a silly mistake by putting | |
// an argument "int a" | |
void func(int a) override | |
{ | |
cout << "I am in derived class" << endl; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment