Priority between normal function and Template function

前端 未结 2 1613
孤城傲影
孤城傲影 2021-01-12 20:28

In the following code, the main function uses normal function instead of Template function.

#include 

using namespace std;

template 

        
2条回答
  •  -上瘾入骨i
    2021-01-12 21:28

    To call the template method in this case, you need to invoke the method explicitly with num(5) instead of num(5). Although the compiler can infer, non-generic method is preferred to a generic one. You can take a look at this behavior here http://ideone.com/ccDJP.

提交回复
热议问题