小编prv*_*e17的帖子

为什么最大两个字符串文字的输出是错误的?

有人可以解释一下,为什么这段代码中的输出是“C”?

#include <iostream>
using namespace std;
template<class X>
X maximum(X a,X b)
{
    if(a > b)
        return a;
    else 
        return b;
}

int main() {
    cout << maximum("C","D") << endl;
}
Run Code Online (Sandbox Code Playgroud)

c++ templates string-literals

3
推荐指数
1
解决办法
116
查看次数

标签 统计

c++ ×1

string-literals ×1

templates ×1