inheritance - Override a non-virtual method in C++ -


i have class a , class b inherits a. a has foo method override in b.

class { public:     void foo();     ... }  class b: public { public:     void foo();     ... } 

the solution of course define a::foo() virtual method, declaring virtual void foo();. problem can't that, since a class defined in third-party library rather not change code.

after searching, found override keyword (so declaration b::foo void foo() override;), didn't me since that's not override for, override can apparently used on virtual methods sure method overriding method , programmer didn't make mistake, , generates error if method isn't virtual.

my question how can achieve same effect making a::foo virtual without changing of code a, code b?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -