我正在嘗試製作用戶類的指針,並將其指定給教師或工作人員的地址。我一直試圖解決這個錯誤很長一段時間,我不能;如何在Visual Studio中處理「First Chance Exception」?
int userType;
User *U=NULL;
string ID, password;
cout << "Please select user type for login -> 1 : Teacher, 2 : Staff : ";
cin >> userType;
cout << endl << "Please key in your ID : ";
cin >> ID;
cout << endl << "Please key in your password : ";
cin >> password;
if (userType == 1){
U = new Teacher();
try{
U->Login(ID, password);
}
catch (std::ifstream::failure e){
cerr << "Exception opening file" << endl;
}
}
else if (userType == 2){
U = new Staff();
try{
U->Login(ID, password);
}
catch (std::ifstream::failure e){
cerr << "Exception opening file" << endl;
}
}
哪個異常和哪裏? – Simon
輸入密碼 –
@MohammedShafras後發生異常,提供最小代碼來重現錯誤。 –