while(true)
{
cout << "Name: ";
getline(cin, Name);
if(Name == "Stop")
break;
cout << "Additional Name - Y/N: ";
getline(cin, additional);
if (additional == "Y")
cout << "Additional Name: ";
getline(cin, Name2);
else
cout << "Location: ";
getline(cin, Location);
if(Location == "Stop")
break;
}
chief.cpp: In member function ‘void BookList::Fill()’:
chief.cpp:128: error: ‘else’ without a previous ‘if’
用户输入名字后,我想提供输入第二个名字的选项。如果“N”直接跳到位置,如果“Y”跳到 Name2,然后跳到 Location。