在setter方法中設置字符串時需要做些什麼不同嗎?這是我的班級:在setter方法中設置字符串
class SavingsAccount
{
public:
void setData();
void printAccountData();
double accountClosure() {return (accountClosurePenaltyPercent * accountBalance);}
private:
int accountType;
string ownerName;
long ssn;
double accountClosurePenaltyPercent;
double accountBalance;
};
void SavingsAccount::setData()
{
cout << "Input account type: \n";
cin >> accountType;
cout << "Input your name: \n";
cin >> ownerName;
cout << "Input your Social Security Number: \n";
cin >> ssn;
cout << "Input your account closure penalty percent: \n";
cin >> accountClosurePenaltyPercent;
cout << "Input your account balance: \n";
cin >> accountBalance;
}
int main()
{
SavingsAccount newAccount;
newAccount.setData();
}
@Jet - 不要在每行之後加上'
'來格式化您的代碼。使用代碼塊功能(位於編輯框的頂部)。現在修復。 – 2009-11-14 01:22:10
好的。我想知道是否有什麼東西。我不知道它在哪裏! – Crystal 2009-11-14 01:30:56