のフィールドにアクセスする方法について特定のメソッドを作成しましたclass
が、先生から、を使用するように言われましたenum
。
enum
sを使用せずに使用するようにこのコードを書き直すにはどうすればよいgoto
ですか?
void SetType() {
cout << "Book SetType" << endl;
Choice: cout << "Please Select from the list: \n "
<< "1- Technical literature \n "
<< "2- Fiction literature \n "
<< "3- Textbook" << endl;
int i;
cin >> i;
switch (i) {
case 1:
Type = "Technical literature";
break;
case 2:
Type = "Fiction literature";
break;
case 3:
Type = "Textbook";
break;
default:
cout << "Erorr you entered a wrong choice" << endl;
goto Choice;
}
}