#include <iostream>
#include <cstring>
using namespace std;
class Internet
{
public:
Internet(char *name,char *url)
{
this->name = new char[strlen(name)+1];
this->url = new char[strlen(url)+1];
if(name!=NULL)
{
strcpy(this->name,name);
}
if(url!=NULL)
{
strcpy(this->url,url);
}
}
Internet(Internet &temp)
{
this->name=new char[strlen(temp.name)+1];
this->url=new char[strlen(temp.url)+1];
if(this->name)
{
strcpy(this->name,temp.name);
}
if(this->url)
{
strcpy(this->url,temp.url);
}
}
~Internet()
{
delete[] this->name;
delete[] this->url;
}
Internet& operator =(Internet &temp)//赋值运算符重载函数
{
delete[] this->nam
C++读书笔记之重载赋值运算符 overload assignment operator
最新推荐文章于 2023-08-19 07:40:46 发布