本文整理汇总了C++中BankAccount::withdraw方法的典型用法代码示例。如果您正苦于以下问题:C++ BankAccount::withdraw方法的具体用法?C++ BankAccount::withdraw怎么用?C++ BankAccount::withdraw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BankAccount
的用法示例。
在下文中一共展示了BankAccount::withdraw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: withdrawl
void withdrawl(BankAccount account[], int num_accts){
int accountnum = 0;
//prompt the user for an account number
accountnum = accountNumPrompt();
//validate that account number
accountnum = find_acct(account, num_accts, accountnum);
if(accountnum == -1){
//give error if its not found
string message = "We couldn't find an account by that number";
error(message);
withdrawl(account, num_accts);
}else{
//keep asking until you get a valid amount
BankAccount * b = &account[accountnum];
while(true){
double howmuch = 0.00;
cout << endl << "How much do you want to withdraw?" << endl;
cin >> howmuch;
if(b->withdraw(howmuch)){
cout << endl << howmuch << " has been withdrawn from account: " << b->getAccountNumber() << endl;
break;
}else{
cout << "Acount " << b->getAccountNumber() << " does not have sufficient funds." << endl;
}
}
}
}
示例2: main
int main ()
{
BankAccount one{"Fist one", "Three hundre", 300};
BankAccount two = BankAccount("Second two", "zero");
BankAccount three = BankAccount();
one.show();
one.deposit(500);
two.show();
three = BankAccount("one million", "one million", 100000);
three.show();
three.withdraw(7852);
three.show();
one.show();
return 0;
}
示例3: mainMenu
//.........这里部分代码省略.........
cin.ignore();
cin >> minPrice;
}
stockObj.sellStock(&Node(stockSymbol, numberShare), minPrice);
break;
case 5:
// view matlab graph
cout << "\nPlease select the time period in the graph: " << endl;
cout << "Start Date (mm/dd/yyyy): ";
cin >> time_start;
cout << "\nEnd Date (mm/dd/yyyy): ";
cin >> time_end;
stockObj.viewGraph(time_start, time_end);
break;
case 6:
// view transaction history
stockObj.viewHistory();
break;
} // end stock switch
} while ( stockChoice != 7 );
break;
} // end case 1
case 2:
{
// bank menu
cout << "\nBank Account" << endl;
// update balance
bankObj.setBalance(stockObj.getBalance());
int bankChoice; // choice for bank menu
double amount; // amount of money to deposit or withdraw
do {
bankInstruction();
cin >> bankChoice;
while (cin.fail()){
cout << "\nPlease enter an integer value: ";
cin.clear();
cin.ignore();
cin >> bankChoice;
}
switch ( bankChoice ) {
case 1:
// view account balance
bankObj.viewBalance();
break;
case 2:
// deposit
cout << "Please select the amount you wish to deposit: $";
cin >> amount;
while (cin.fail()){
cout << "\nPlease enter a double value: $";
cin.clear();
cin.ignore();
cin >> amount;
}
bankObj.deposit(amount);
break;
case 3:
// withdraw
cout << "Please select the amount you wish to withdraw: $";
cin >> amount;
while (cin.fail()){
cout << "\nPlease enter a double value: $";
cin.clear();
cin.ignore();
cin >> amount;
}
bankObj.withdraw(amount);
break;
case 4:
// print history
bankObj.printHistory();
break;
} // end bank switch
} while ( bankChoice != 5 );
break;
} // end case 2
} // end main switch
} while ( mainChoice != 3 );
}