Last active
January 29, 2016 18:02
-
-
Save stephan-vandenheuvel/b538a7b827995f9b4988 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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