程序改动
#include <iostream> using namespace std;
class Internet
{
public:
Internet(char *name,char *ur1)
{
Internet::name = new char[strlen(name)+1];
Internet::url =new char[strlen(ur1)+1];
if(name)
{
strcpy(Internet::name,name);
}
if(url)
{
strcpy(Internet::url,ur1);
}
}
public:
char *name;
char *url;
};
int main()
{
Internet a("中国软件开发实验室",");
system("parse");
}
上面的程序中把Internet::url =new char[strlen(ur1)+1];改成Internet::url =ur1;有什么不妥吗?