c++实现 一个客户帐号

c++实现 一个客户帐号

 
 
//110.h  头文件
#ifndef WYZ_1
#define WYZ_1
#include<iostream>
#include<string>
class point
{
private:
int nsize,asize;
char*  name;
char* account;
double saving;
public:
point();
point(char*,char*,double);
point(std::string &,std::string &,double);
point::point(const point& bank);
point& operator=(const point& bank);

    inline void funsaving(double);
  
  
friend std::ostream& operator<<(std::ostream &os,const point & bank);
~point();
};
#endif




#ifndef WYZ_WYZ_
#define WYZ_WYZ_
class coustomer
{
private:
long arrive;
int processtime;
public:
coustomer() {arrive=processtime=0;}
void set(long when);
long when()const {return arrive;}
int ptime()const {return processtime;}
};
typedef coustomer Item;
class queue
{
private:
struct Node{Item item;struct Node *next;};
enum { Q_SIZE=10};
Node *front;
Node *reat;
int items;
const int qsize;
queue(const queue &q):qsize(0){}
queue & operator=(const queue &q){ return *this;}
public:
queue(int qs=Q_SIZE);
~queue();
bool isempty()const;
bool isfull()const;
int queuecount()const;
bool enqueue(const Item &item);
bool dequeue(Item &item);
};
#endif

#include"110.h"
#include<cstdio>
inline void point::funsaving(double dsaving)
 {
 saving=dsaving;
}
point::point()
{
        asize=nsize=4;
     name=new char[nsize];
  strncpy(name,"***",nsize);
 
  account=new char[asize];
 strncpy(account,"***",asize);
  saving=0;
 }
point::point(char *strname,char* straccount,double dsaving)
{
 nsize=strlen(strname);
 name=new char[nsize+1];
 strcpy(name,strname);
    asize=strlen(straccount);
 account=new char[asize+1];
 strcpy(account,straccount);

 saving=dsaving;
}
point::point(std::string &strname,std::string &straccount,double dsaving)
{
 nsize=strname.size();
    name=new char[nsize+1];
 strcpy(name,strname.c_str());
 asize=straccount.size();
 account=new char[asize+1];
 strcpy(account,straccount.c_str());
 saving=dsaving;
}
point& point::operator=(const point& bank)
{
  nsize=bank.nsize;
  name=new char[nsize+1];
  std::strcpy(name,bank.name);
  //.........................
  asize=bank.asize;
  account=new char[asize+1];
  std::strcpy(account,bank.account);
  saving=bank.saving;
     return bank;
 }
point::point(const point& bank)
{
     nsize=bank.nsize;
  name=new char[nsize+1];
  std::strcpy(name,bank.name);
  //.........................
  asize=bank.asize;
  account=new char[asize+1];
  std::strcpy(account,bank.account);
  saving=bank.saving;
}
point::~point()
{
 delete[]account;
 delete[]name;
}
 std::ostream& operator<<(std::ostream& os,const point& bank)
{
 os<<"姓名:"<<bank.name<<std::endl<<"帐号:"<<bank.account<<std::endl<<"余额:"<<bank.saving<<std::endl;
 return os;
}

#include<iostream>
#include<string>
#include"110.h"
int main()
{
 using namespace std;
 cout.setf(ios_base::fixed,ios_base::floatfield);
 cout.precision(4);
    string name,account;
 double saving;
    getline(cin,name);
 getline(cin,account);
 cin>>saving;
    point wqn(name,account,saving),qan;
 cout<<wqn<<endl<<qan;
 cin>>saving;
 wqn.funsaving(saving);
 cout<<wqn;
    cout<<"另一个"<<endl;
 point stg=point("qwer","utryuyytr",456.123);
 cout<<stg<<endl<<endl;
 wqn=stg;
 cout<<stg;
 return 0;
}
 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值