Is it possible to write a switch case constructor with a string type of C ++ variables ???

  • one
    If you mean: use switch with string - no. - Andrej Levkovitch
  • Until C ++ 17, definitely not. - Rikitikitavi
  • one
    and it's not at all clear what you mean by: the switch case - switch constructor is not a class, it is an operator that, if I'm not mistaken, cannot be overloaded. If you want to write your class, similar to switch, then you will have to call it differently, since this name is already taken. And, to be honest, I do not imagine a convenient class, an analogous switch. - Andrej Levkovitch
  • take std :: map, but do not suffer. - JaponDemon
  • Too lazy to write if? ) You can try to hash and then compare them if you really want a switch-case. - Vladimir Ch.

0