+ 4
About switch-case (C++)
Can i put string with cases. For example switch(var) { case "hello" : cout << "Hello" ; break ....
3 odpowiedzi
+ 9
Not in C/C++, at least not directly, because strings aren't considered integral values.
https://en.cppreference.com/w/cpp/language/switch
"... any expression of integral or enumeration type, or of a class type contextually implicitly convertible to an integral or enumeration type... "
+ 5
Additional info:
Is there a workaround? Yes, such as hashing.
https://stackoverflow.com/questions/2111667/compile-time-string-hashing
+ 4
Thanks for inf