C++: inheriting overloaded non-virtual method and virtual method both with the same name causes problem -


I am trying to get two equally named designated methods for the same category with different parameter lists . One of them is virtual and override in the derived class, the other one is non-virtual. By doing so, I receive a compilation error while trying to access the non-virtualization of the base class from the client object I received.

Here is the code snippet

  class base {public: void f () {cout & lt; & Lt; "[Base :: f ()]" & lt; & Lt; Endl; } Virtual Zero (int arg) {cout & lt; & Lt; "[Base: F (" <<  

generates the following compile error:

Error: No matching function to call for 'Deriv :: f ()' function: Note: Candidates are: Virtual Zero Deriv :: f (int)

I am not an expert in C ++, but so far I have been right in making this assumption that members Methods can be completely separated by their signature, non-virtual method base :: F () should not be override and Should be accessible. Am I wrong with this?

Here are some interesting / additional comments:

    - Overriding method Deriv :: f (int arg) can also be non-virtual; The error happens in any way
    - the error disappears / can be intruded ...
      ... by casting the deriv object for the base class
      ... when not the base Deriv in override :: f (int arg)
      ... "base :: f;" For the public part of Deriv

Therefore, because I already know how to avoid the error of this compilation, I mainly use why Interested in this error! Please help me highlight that ...

Thanks Advanvce! Emme

In the Deriv , add it:

  Base :: F; In addition to the link provided by @DumbCoder, you can find more details in response to a similar question: 


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -