C++实验一 类与对象(8)
发布时间:2021-06-06
发布时间:2021-06-06
4.#include<iostream> using namespace std; class account { private: int user; double balance; //余额 public: int cipher; //账户密码 account(int user=0) { cipher=0; balance=0; cout<<"新账户"<<user<<"建立了。"<<endl; }
~account() { cout<<"账户号"<<user<<"被删除了!"<<endl; cout<<"账户"<<user<<"的余额为:"<<balance<<endl; } void save(double x) //存款 { balance=balance+x; } void draw(double x) //取款 { balance=balance-x; } int queryuser(int m) //查询用户 { return user=m; } void querymoney() //查询余额 { cout<<"用户"<<user<<"的余额为:"<<balance<<endl; } int judge(int &m) { int key; if(m==user) { cout<<"请输入密码:"<<endl; cin>>key; if(key==cipher)
下一篇:primerstar 说明书