Search code examples
c++lettersimplicit-conversion

Implicit casting letters in c++


Does this line

char chValue = max('a', '6'); // returns 'a'

int max(int nX, int nY)
{
return (nX > nY) ? nX : nY;
}

cast the letter 'a' to its ASCII equivalent number then compare it to the integer?


Solution

  • Yes, because max is a function that takes two ints as arguments, the char a will get implicitly converted into an int and then get passed as an argument of the function.