C++: Why member function has priority over global function

前端 未结 6 758
青春惊慌失措
青春惊慌失措 2020-12-17 21:14

Why in the next program the member function foo has priority over the global foo although the global one match the type?

#include 
using name         


        
6条回答
  •  执笔经年
    2020-12-17 21:36

    One of the tenets of method overloading is that the specific should trump the general. In your example, the member method will always be more specific than a global method.

提交回复
热议问题