#include<iostream>
#include<cstring>
using namespace std;
class Account
{``
private:
char m_name[10];
char m_zh[20];
double m_money;
public:
Account(char name[],char zh[],double money);
void show();
void add(double money);
void get(double money);
};
Account::Account(char name[],char zh[],double money)
{
strcpy(m_name,name);
strcpy(m_zh,zh);
m_money=money;
}
void Account::show()
{
cout<<"User name:"<<m_name<<endl;
cout<<"User zh:"<<m_zh<<endl;
cout<<"User money:"<<m_money<<endl<<endl;
}
void Account::add(double money)
{
m_money+=money;
}
void Account::get(double money)
{
if(m_money>=money)m_money-=money;
else
cout<<"ERROR"<<endl;
}
int main()
{
Account U("River","Distance",10000);
U.show();
U.add(20000);
U.show();
U.get(5000);
U.show();
return 0;
}
银行账户系统
最新推荐文章于 2024-07-26 02:07:01 发布