百科知识

C++设计一个account类,实现银行某张好的资金往来帐目管理

2018-04-08 05:03:46巴***
设计一个account 类,实现银行某张好的资金往来帐目管理,包括建帐号,存入,取出,输出帐号的所有信息。 快,随便能实现就行!C++设计一个account类,实现银行某张好的资金往来帐目管理,包括建帐号,存入,取出,输出帐号的所有信息。快,随便能实现就行!:Account类的头文件 ?

最佳回答

  •   Account类的头文件 //Account。h #ifndef ACCOUNT_H_ #define ACCOUNT_H_ #include using std::string; class Account { private: string name; //帐户名 string password; //密码 int deposit; //存款 bool modify; //帐户是否被修改 public: Account(); Account(string na, string psw, int dps); ~Account(); bool openAccount(string accName); //从文件打开帐户 bool saveAccount(); //将帐户保存到文件 bool land(string psw); //帐户登录 bool saving(int money); //存款 bool fetch(int money); //取款 void showBalance(); //显示余额 }; #endif Account类的实现,在Account。
      cpp文件中 //Account。cpp #include #include #include #include "Account。h" using namespace std; Account::Account() { name = ""; password = ""; deposit = 0; } Account::Account(string na, string psw, int dps) { name = na; password = psw; deposit = dps; } Account::~Account() { } bool Account:penAccount(string accName) { ifstream fin(accName。
      c_str(), ios_base::in); if(! _open()) { std::cout>name; fin>>password; fin>>deposit; ose(); return true; } bool Account::saveAccount() { if(modify == false) return true; ofstream fout; fout。
      open(name。c_str(), ios_base:ut); if(! _open()) { std::cout<<"保存帐户错误,不能创建文件!"<   。
    2018-04-08 05:13:19
  •   Account类的头文件 //Account。h #ifndef ACCOUNT_H_ #define ACCOUNT_H_ #include using std::string; class Account { private: string name; //帐户名 string password; //密码 int deposit; //存款 bool modify; //帐户是否被修改 public: Account(); Account(string na, string psw, int dps); ~Account(); bool openAccount(string accName); //从文件打开帐户 bool saveAccount(); //将帐户保存到文件 bool land(string psw); //帐户登录 bool saving(int money); //存款 bool fetch(int money); //取款 void showBalance(); //显示余额 }; #endif Account类的实现,在Account。
      cpp文件中 //Account。cpp #include #include #include #include "Account。h" using namespace std; Account::Account() { name = ""; password = ""; deposit = 0; } Account::Account(string na, string psw, int dps) { name = na; password = psw; deposit = dps; } Account::~Account() { } bool Account:penAccount(string accName) { ifstream fin(accName。
      c_str(), ios_base::in); if(! _open()) { std::cout>name; fin>>password; fin>>deposit; ose(); return true; } bool Account::saveAccount() { if(modify == false) return true; ofstream fout; fout。
      open(name。
      c_str(), ios_base:ut); if(! _open()) { std::cout<<"保存帐户错误,不能创建文件!"<2018-04-08 06:13:19
  • 很赞哦! (31)