标签:
#include<iostream> using namespace std; class BankAccount { string m_name; string m_num; unsigned int m_balance; public: BankAccount(string name,string num,unsigned balance) { m_name = name; m_num = num; m_balance = balance; } void show() const { cout << m_name << endl; cout << m_num << endl; cout << m_balance << endl; } void inDeposit(unsigned amount) { m_balance = m_balance + amount; } void deDeposit(unsigned amount) { if(m_balance < amount) m_balance = 0; else m_balance = m_balance - amount; } }; int main() { BankAccount bank("Jack","123",10000); bank.show(); bank.inDeposit(1000); bank.show(); bank.deDeposit(1500); bank.show(); }
C++ Prime Plus第十章的练习。
标签:
原文地址:http://www.cnblogs.com/fudianheg/p/4234479.html