下载一个vc6.0的补丁包打上就行
SZYString SZYString::operator+(SZYString &str2){
size = size + 20;
char* newstr = new char[size];
for (int i = 0; i < end; i++) {
newstr[i] = str[i];
}
delete []str;//这句不需要的吧
for (int j = end; j < (end + str2.end); j++) {
newstr[j] = str2.str[j - end];
}
str = new char[size];
for (int m = 0; m < (end + str2.end); m++) {
str[m] = newstr[m];
}
end = end + str2.end;
delete newstr;//这句是不是delete[] newstr;
return str;
构造函数:
SZYString::SZYString(const char* a)
{
end = 0;
for (int j = 0; a[j] != '\0'; j++) {
end += 1;
}
size = 20;
while (end >= size) {
size = size + 20;//这句是不是该这样size = end + 20
}
str = new char[size];
for (int i = 0; a[i] != '\0'; i++) {
str[i] = a[i];
}
}
检查一下代码有没有什么逻辑错误