![]() |
#2
ly8610142009-08-19 10:38
|

class text
{
public:
text(char* s) //s是一个指针吗,str=new char[strlen(s)+1];中的s是指指向str字符串的指针?
{
str=new char[strlen(s)+1]; //这里是不是动态分配,象一般是这样char* p=new char[],有什么区别?
strcpy(str,s);
len=strlen(s);
}
...
void main()
{
text array("good morning");
...
}
{
public:
text(char* s) //s是一个指针吗,str=new char[strlen(s)+1];中的s是指指向str字符串的指针?
{
str=new char[strlen(s)+1]; //这里是不是动态分配,象一般是这样char* p=new char[],有什么区别?
strcpy(str,s);
len=strlen(s);
}
...
void main()
{
text array("good morning");
...
}