Skip to content

Instantly share code, notes, and snippets.

@chichunchen
Last active April 19, 2019 22:45
Show Gist options
  • Save chichunchen/259f9fbed52f00de5acd406f31f88205 to your computer and use it in GitHub Desktop.
Save chichunchen/259f9fbed52f00de5acd406f31f88205 to your computer and use it in GitHub Desktop.
#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