I cant put a string in a switch nor an array in a class
- by TimothyTech
Okay, im making a pretty big file in my opinion, so i wanted to separate it into several files for cleaner code. so i have my main .cpp file and two header files holding my classes. well the header files dont hold strings, it aboslutely wont budge. i call the library in both my .cpp file and even tried it in my header file.
another issue i ran into is using strings to make switches function, reason being if i use integers in a switch if the user inputs a alphabetical character the program goes into an endless loop.
string choice;
switch (choice)
{
case "1" :
//...
break;
case "2" :
//...
break;
}
and my last issue is when i create an object in a case it gives an error. says cross initialization of object.
string choice;
switch (choice)
{
case "1" :
Class object;
break;
case "2" :
//...
break;
}