What's the difference between char and int in a switch case?

前端 未结 8 1708
别跟我提以往
别跟我提以往 2021-01-13 11:21

I started C++ recently and while learning switch case, I got this doubt.
What\'s the difference if I use int or char in the following code :
int Fav_Car;

8条回答
  •  耶瑟儿~
    2021-01-13 11:51

    because '1' is a char and 1 is an integer. If you want to make integers work , remove the single quotes. Using double quotes makes it a string.

提交回复
热议问题