Skip to content

Instantly share code, notes, and snippets.

@stephan-vandenheuvel
Last active January 29, 2016 18:02
Show Gist options
  • Save stephan-vandenheuvel/b538a7b827995f9b4988 to your computer and use it in GitHub Desktop.
Save stephan-vandenheuvel/b538a7b827995f9b4988 to your computer and use it in GitHub Desktop.
class A
{
void Foo();
}
class B : public A
{
//intended to override A's Foo, but hides it, because A's Foo is non virtual
//including override here would allow the compiler to catch the error
virtual void Foo();
}
A* myptr = new B();
myptr->Foo(); //calls A's Foo
Fix is to make A's Foo virtual, but override will help you realize the error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment