本文整理汇总了C++中BankAccount::tostr方法的典型用法代码示例。如果您正苦于以下问题:C++ BankAccount::tostr方法的具体用法?C++ BankAccount::tostr怎么用?C++ BankAccount::tostr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BankAccount
的用法示例。
在下文中一共展示了BankAccount::tostr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
vector<BankAccount*> accounts;
do
{
int index = 0;
int userAccount = 0;
int choice = menu();
if (choice == 1) //Open
{
int type = accountType();//determines account type
cout << "What name did your mom and pop give you?\n"; //Gathering account info. It makes more sense to me to do this in main with a constructor as opposed to a member function.
string name = "";
cin >> name; //I assume they user will only enter either a first name.
bool validCheck = false;
string initialDeposit;
do //checks if valid choice y or n
{
cout << "Would you like to start with an initial deposit? (y/n)\n";
initialDeposit = "";
cin >> initialDeposit;
if (initialDeposit == "y" || initialDeposit == "n")
{
validCheck = true;
}
else
{
cout << "That isn't one of the choices. Come on now.\n\n";
}
}
while (validCheck == false);
double initialDepositAmount = 0;
if (initialDeposit == "y")
{
bool posCheck = false;
do//Ensures only positive desposits.
{
cout << "How much you wanna deposit?\n";
cin >> initialDepositAmount;
if (initialDepositAmount < 0)
{
cout << "You may only deposit postive money...\n";
}
else
{
posCheck = true;
}
}
while (!posCheck);
}
if (type == 1) //Checking
{
BankAccount* temp = new CheckingAccount(accountCounter, initialDepositAmount, name);
cout << temp->tostr();
accountCounter++;
accounts.push_back(temp);
}
else if (type == 2)//Savings
{
BankAccount* temp = new SavingsAccount(accountCounter, initialDepositAmount, name);
cout << temp->tostr();
accountCounter++;
accounts.push_back(temp);
//Savings.open()
}
else if (type == 3)//CD
{
BankAccount* temp = new CDAccount(accountCounter, initialDepositAmount, name);
cout << temp->tostr();
accountCounter++;
accounts.push_back(temp);
//CD.open()
}
}