Why should I use the “using” keyword to access my base class method?

后端 未结 4 1916
无人共我
无人共我 2020-11-27 11:19

I wrote the below code in order to explain my issue. If I comment the line 11 (with the keyword \"using\"), the compiler does not compile the file and displays this error: <

4条回答
  •  难免孤独
    2020-11-27 12:07

    A note of caution: The need to use a "using" in this situation is a red flag that your code may be confusing for other developers (after all it confused the compiler!). It is likely that you should rename one of the two methods to make the distinction clear to other programmers.

    One possibility:

    void action( const char how )
    { 
      takeAction( &how ); 
    }
    void action( const char * how )
    {
      takeAction(how);
    }
    virtual void takeAction(const char * how) = 0;
    

提交回复
热议问题