64,649
社区成员
发帖
与我相关
我的任务
分享
class Student{
public:
Student(char *s):str(s){ // 这种写法,有没有问题,
for(int i = 0; i < strlen(s); i++)
cout << str[i];}
Student(int , char *s){ // 还是应该使用这种方法, 程序跑的时候,两个都可以正常运行的。求解答,还有原因。谢谢了
str = new char[strlen(s) +1];
strcpy(str,s);
// cout << *str;
}
private:
char *str;
};