How do I convert a string to a switch case in C++?

The solution is very simple. You need an enumeration and a std::map , and that’s it. The enumeration defines the numeric values use in the switch statement. The std::map contains the link between the valid string values you want to compare some runtime data against, and the numeric enum values you can make a switchon.

Sizin İçin Seçtik  What is struct and enum?

Leave a Reply

Your email address will not be published. Required fields are marked *