C++ templated function overloading rules
问题 When overloading a templated function, how should the compiler chose which version of the function to call if it has the option to either: Call a templated version of the function (such as func<T>(foo) ). Call an overloaded version of the function which is not itself templated but where the type of the parameter being passed to the function inherits from the type specified in the overloaded function template. Consider the following C++ code: #include <stdio.h> struct Parent {}; struct Child :