是否这条线
char chValue = max('a', '6'); // returns 'a'
int max(int nX, int nY)
{
return (nX > nY) ? nX : nY;
}
将字母 'a'
转换为其 ASCII 等效数字,然后将其与整数进行比较?
最佳答案
是的,因为 max
是一个接受两个 int
作为参数的函数,char a
将得到 implicitly converted转换为 int
,然后作为函数的参数传递。
关于c++ - C++中的隐式类型转换字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36359620/