Can i create object inside switch case in C++ ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Can i create object inside switch case in C++ ??

31st Jan 2019, 10:18 AM
Pratika
Pratika - avatar
3 Answers
+ 5
Yes you can, but you should probably assign it to an object (or object pointer) of the same type that already exists outside of the switch block, unless you won't need to use it outside of the switch block.
31st Jan 2019, 1:24 PM
Zeke Williams
Zeke Williams - avatar
31st Jan 2019, 1:40 PM
Zeke Williams
Zeke Williams - avatar
31st Jan 2019, 2:04 PM
Earl_Grey
Earl_Grey - avatar