+ 1

Can a string be used instead of int in c++?

In a switch loop.... can I use a string as a switch instead of int? If yes, how to do that?

21st Dec 2016, 12:14 PM
DEF4LT_
DEF4LT_ - avatar
1 ответ
+ 6
Unfortunately, switch statements in C++ does not allow the use of string as case. Int and char are possible, but not string. You will have to utilise if... else statements to proceed with string. I have had similar issues in the past.
21st Dec 2016, 12:29 PM
Hatsy Rei
Hatsy Rei - avatar