the only thing different between char and int is that cout / stream ops are overloaded to make them special snowflakes. You are all correct, depending on where you want to stand near the line of distinction. Its like saying a pointer is an int. It is, but its also not, depending on how much you want to get fired up about the topic... meh. I will leave that stuff to the lawyers that write the standards and spend their time nerfing unions.
g++ x.cpp -O3 -Wall -Wextra -pedantic -std=c++17
does not throw any errors or warnings for
int main()
{
int hmm{'a'};
cout << hmm;
}
good enough for me.
The type int is always a standard signed integer type;
the type char may be an unsigned integer type
The type signed char is a standard signed integer type
The type unsigned char is a standard unsigned integer type
The type char is a distinct type that has an implementation-defined choice of “signed char” or “unsigned char” as its underlying type. https://eel.is/c++draft/basic.fundamental#7
Exactly, and that is the distinction in this case between an int and a char.
A simple example of implementation-defined is the meaning of multiplying 2 integers vs multiplying 2 characters or multiplying 2 bools.
@lastchance that's OK I interpreted it otherwise and despite your other (more noble @OP-oriented ) purpose it raised a question about the char/int that had me stumped. If it had disproved what I commented on I would have accepted it as my error. However, I find that a lot has been written about auto and hence my comment.
As a matter of choice I avoid auto. As it turns out my previous intuition not to use it now has a firm basis. Thanks for your unwittingly useful demo :)
( Either way, a char is an int is incorrect, just as