C++ overloaded function issue

前端 未结 1 672
清歌不尽
清歌不尽 2021-01-26 04:37

Why does the compiler not find the base class function signature? Changing foo( a1 ) to B::foo( a1 ) works.

Code:

class A1 ;
cl         


        
相关标签:
1条回答
  • 2021-01-26 05:05

    The name C::foo shadows the name B::foo. Once the compiler finds the matching foo in class C, it stops searching any further.

    You can resolve your problem by adding:

    using B::foo;
    

    to the body of class C, or by renaming the function in class B.

    0 讨论(0)
提交回复
热议问题