For example, in this code:
#include <iostream>
int main()
{
enum:char
{ a = 'a', b = 'b', c = 'c', NEWLINE = '\n' };
std::cout << a << b << c << NEWLINE;
return 0;
}
a
, b
, c
, and NEWLINE
print out as ASCII codes.
I am learning C++, and so far I understand pretty much everything I have studied. I know that enumerated types hold constant integral values, but I did not expect a value of type char to be displayed as an integral value (at least not without having to explicitly cast it).
I am curious why this occurs with enumerations? I have not been able to find a reason for why this is happening.