#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);
#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);
void funsaving(double){ saving=dsaving;}
friend std::ostream& operator<<(std::ostream &os,const point & bank);
~point();
};
#endif
friend std::ostream& operator<<(std::ostream &os,const point & bank);
~point();
};
#endif
//.................................................................................................................................
#include"110.h"
#include<cstdio>
point::point()
{
asize=nsize=4;
name=new char[nsize];
strncpy(name,"***",nsize);
account=new char[asize];
strncpy(account,"***",asize);
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);
}
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);
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)
{
}
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)
{
if(this==&bank)
return *this;
delete[] 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 *this;
}
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;
}
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 *this;
}
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;
}
{
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;
}
#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;
}
我刚开始学c++。望师兄们指点。