这道题看不懂,有人可以帮我把每句话的含义写一下吗?#include #define NULL 0class string{private:char* ptr;public:string(char* str=NULL){int i;char *p;for(i=0;str[i]!='\0';i++);ptr=new char [i+1];for(p=ptr;*str!='\0';str++,p++)*p=*s
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/26 02:21:05
![这道题看不懂,有人可以帮我把每句话的含义写一下吗?#include #define NULL 0class string{private:char* ptr;public:string(char* str=NULL){int i;char *p;for(i=0;str[i]!='\0';i++);ptr=new char [i+1];for(p=ptr;*str!='\0';str++,p++)*p=*s](/uploads/image/z/5332781-29-1.jpg?t=%E8%BF%99%E9%81%93%E9%A2%98%E7%9C%8B%E4%B8%8D%E6%87%82%2C%E6%9C%89%E4%BA%BA%E5%8F%AF%E4%BB%A5%E5%B8%AE%E6%88%91%E6%8A%8A%E6%AF%8F%E5%8F%A5%E8%AF%9D%E7%9A%84%E5%90%AB%E4%B9%89%E5%86%99%E4%B8%80%E4%B8%8B%E5%90%97%3F%23include+%23define+NULL+0class+string%7Bprivate%3Achar%2A+ptr%3Bpublic%3Astring%28char%2A+str%3DNULL%29%7Bint+i%3Bchar+%2Ap%3Bfor%28i%3D0%3Bstr%5Bi%5D%21%3D%27%5C0%27%3Bi%2B%2B%29%3Bptr%3Dnew+char+%5Bi%2B1%5D%3Bfor%28p%3Dptr%3B%2Astr%21%3D%27%5C0%27%3Bstr%2B%2B%2Cp%2B%2B%29%2Ap%3D%2As)
这道题看不懂,有人可以帮我把每句话的含义写一下吗?#include #define NULL 0class string{private:char* ptr;public:string(char* str=NULL){int i;char *p;for(i=0;str[i]!='\0';i++);ptr=new char [i+1];for(p=ptr;*str!='\0';str++,p++)*p=*s
这道题看不懂,有人可以帮我把每句话的含义写一下吗?
#include
#define NULL 0
class string
{
private:
char* ptr;
public:
string(char* str=NULL)
{
int i;
char *p;
for(i=0;str[i]!='\0';i++);
ptr=new char [i+1];
for(p=ptr;*str!='\0';str++,p++)
*p=*str;
*p='\0';
}
int compare(string &str)
{
char *p=ptr,*q=str.ptr;
for(;*p!='\0'||*q!='\0';p++,q++)
{
if(*p>*q)
return 1;
else
if(*p
这道题看不懂,有人可以帮我把每句话的含义写一下吗?#include #define NULL 0class string{private:char* ptr;public:string(char* str=NULL){int i;char *p;for(i=0;str[i]!='\0';i++);ptr=new char [i+1];for(p=ptr;*str!='\0';str++,p++)*p=*s
对不起