C++是拷贝构造函数与赋值运算符重载
----------------------------------griddata.h头文件-------------------------------------
#ifndef GRIDDATA_H
#define GRIDDATA_H
class GridData
{
public:
CString number;//产品编号
CString date; //测试日期
CString people_test; //测试人员
CString people_check; //检验人员
CString people_record; //记录人员
CString title; //表格的标题
public:
GridData();
GridData(const GridData& data); //拷贝构造函数,请注意定义的格式
GridData& operator=(const GridData &data); //赋值运算符重载,请注意定义的格式
};
#endif
---------------------------------griddata.cpp文件----------------------------------
GridData::GridData(){}
GridData::GridData(const GridData& data) //拷贝构造函数
{
this->number=data.number;
this->date=data.date;
this->people_check=data.people_check;
this->people_record=data.people_record;
this->people_test=data.people_test;
this->title=data.title;
}
GridData& GridData::operator =(const GridData& data) //赋值运算符重载
{
this->number=data.number;
this->date=data.date;
this->people_check=data.people_check;
this->people_record=data.people_record;
this->people_test=data.people_test;
this->title=data.title;
return *this;
}

浙公网安备 33010602011771号