i"m new at this.. please help me! i keep getting this error Error 5 error C2360: initialization of 'levelOne' is skipped by 'case' label.
I get a "transfer of control bypasses initialization of:" error when i try to build the following switch:
void ViewCourses() {
int choice = 0;
cout<<"Please select your level:"<<endl;
cout<<"1) level one"<<endl;
cout<<"2) level two"<<endl;
cout<<"3) level three"<<endl;
cout<<"4) level four"<<endl;
cout<<"5) level five"<<endl;
cout<<"Please enter Level: ";
cin >> choice;
switch(choice)
{
case 1: ifstream levelOne;
levelOne.open("level1.txt");
break;
case 2: ifstream levelTwo;
levelTwo.open("level2.txt");
break;
case 3: ifstream levelThree;
levelThree.open("level3.txt");
break;
case 4: ifstream levelFour;
levelFour.open("level4.txt");
break;
case 5: ifstream levelFive;
levelFive.open("level5.txt");
break;
default: cout << "Invalid option please try again" << endl;//when an incorrect option is entered
break;
}
}