显示复制构造函数与赋值函数模型
/////////////////赋值/////////////////////////////////
baseDMA & baseDMA::operator=(const baseDMA & rs)
{
if (this == &rs)
return *this;
delete [] label;
label = new char[strlen(rs.label) + 1];
strcpy(label, rs.label);
rating = rs.rating;
return *this;
}
hasDMA & hasDMA::operator=(const hasDMA & rs)
{
if (this == &rs)
return *this;
baseDMA::operator=(hs);
style = new char[strlen(rs.style) + 1];
strcpy(style, rs.style);
return *this;
}
/////赋值构造/////////////////////////////
baseDMA::baseDMA(const baseDMA & rs)
{
label = new char[strlen(rs.label) + 1];
strcpy(label, rs.label);
rating = rs.rating;
}
hasDMA::hasDMA(const hasDMA & hs):baseDMA(hs)
{
style=new char[strlen(hs.style)+1];
strcpy(style,hs.style);
}
////////////////析构//////////////////////////
baseDMA::~baseDMA()
{
delete [] label;
}
hasDMA::~hasDMA()
{
delete [] style;
}


浙公网安备 33010602011771号