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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -