Is there something I need to do differently in setting a string in a setter method? This is my class:
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();
}