0
我在編譯器收到以下錯誤:建立一個ifstream的,得到。「的錯誤:之前預計初始 '令牌'
AccountDB.cpp:在成員函數「void AccountDB :: processTransactions(爲const char * )': AccountDB.cpp:89:9:error:expected initializer before'。'token inFile2.open(transactFile); ^(胡蘿蔔過期)
這是相關功能。從這裏的類似錯誤,我懷疑它與命名空間有關,但我不確定是哪一個。該函數應該讀取日期,帳號和事務數量,然後使用其他嵌套函數對其進行處理。
void AccountDB::processTransactions(const char* transactFile)
{
//set up the input stream from the text file
ifstream inFile2;
//set up the variables to be read from text file
char date[6];
char type;
char accountnumber[20];
double amount,
//open the file
inFile2.open(transactFile);
//standard check for file and exit if it doesn't exist
if(!inFile2)
{
cout << "Error, input file could not be opened.\n";
exit(1);
}
//Creates a header for listing transactions
cout << setw(5) << "Date"
<< setw(25) << "Account Number"
<< setw(5) << "Type"
<< setw(8) << "Amount"
<< setw(30) << "New Balance"
<< endl;
inFile2 >> date;
while (inFile2)
{
inFile2 >> accountnumber >> type >> amount;
cout << setw(5) << date
<< setw(25) << accountnumber[20]
<< setw(5) << type
<< setw(8) << amount;
int relevantAccount = searchForAccount(accountnumber);
if (relevantAccount != -1)
{
if (type == 'P')
{
credArray[relevantAccount].processPayment(amount);
cout << setw(30) << credArray[relevantAccount].getBalance() << endl;
}
else
{
bool chargestatus = credArray[relevantAccount].processCharge(amount);
if (chargestatus = 1)
cout << setw(30) << credArray[relevantAccount].getBalance() << endl;
else
cout << "Credit limit exceeded" << endl;
}
}
else
cout << "Invalid account number" << endl;
inFile2 >> date;
}
cout << "End of transaction list." << endl;
}
哦哇...我所有的調試,我錯過了?嘖。感謝您的幫助! – qwerty26