redefine a non-virtual function in C++ -


When I read Effective C ++, it says, sometimes a non-virtual function in C ++ It is not defined again

However, when I tested it, the code below was compiled correctly. So what's the matter? Is this a mistake or just a bad practice?

  class A {public: zero F () {cout & lt; & Lt; "A.f ()" & lt; & Lt; Endl;}; }; Class B: Public A (public: zero F) (cout << bf () " 

A non-virtual function It is okay to redefine it, as long as you are not dependent on the virtual remittance behavior

The author of the book is afraid that you will pass a B * function to a < Code> A * and then can be disturbed when the result is a call to the base method, not the view Pnn method.


Comments

Popular posts from this blog

objective c - iPhone and it's wireless area -

unix - Listing all shared memory segments used by a process on AIX5.3+ -

tsql - Correct sql/hql query (aggregate in where clause) -