
这样写提示不接受两个参数,但是如果改成strcpy_s(Name,20,name);就对了,为什么呢?求大神解答!!!
下面是整个程序:
#include<iostream>
using namespace std;
class Student
{
char Num[10];
char *Name;
int Score;
public:
Student(char *num, char *name, int s)
{
strcpy_s(Num, num);
Name = new char[10];
strcpy_s(Name,20,name);
Score = s;
}
~Student()
{
delete[]Name;
}
void Show()
{
cout << Num << " " << Name << " " << Score << endl;
}
};
int main()
{
Student s1("123", "xiaoli", 23);
Student *s2 = new Student("124", "xiaoming", 21);
s1.Show();
s2->Show();
delete s2;
system("pause");
return 0;
}