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;
Are you sure that INT is not working?
The following code works well:
#include
int main() {
int fav_car = 2;
switch(fav_car) {
case 1 :
std::cout<< "That's cool";
break;
case 2 :
std::cout<< "Even mine!";
break;
default :
std::cout<< "Oh";
break;
}
}
case '1' - it is a symbol
case "1" - it is a string constant