在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