当前位置: 首页>>代码示例>>C++>>正文


C++ BankAccount::tostr方法代码示例

本文整理汇总了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()
			}
		}
开发者ID:matthewkirk203,项目名称:CS142,代码行数:79,代码来源:Main.cpp


注:本文中的BankAccount::tostr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。