|
1鱼币
#include<iostream>
using namespace std;
#include<string.h>
class Person
{
public:
Person(char *Name,char Sex,int Age)
{
strcpy(name,Name);
sex=Sex;
age=Age;
cout<<"The constructor"<<endl;
}
~Person()
{
cout<<"The destructor"<<endl;
}
void show()
{
cout<<"name:"<<name<<endl;
cout<<" sex"<<sex<<endl;
cout<<" age"<<age<<endl;
}
protected:
char name{11};
char sex;
int age;
};
class Student:public Person
{
public:
Student(char *Name,char Sex,int Age,char *Id,char *Date,float Score):Person(name,sex,age)
{
strcpy(id,Id);strcpy(date,Date);score=Score;
cout<<"The constructor of derived"<<endl;
}
void StuShow()strcpy(name,Name);
{
cout<<" id"<<id<<endl;
cout<<" name"<<name<<endl;
cout<<" sex"<<sex<<endl;
cout<<" age"<<age<<endl;
cout<<" enrollment date"<<date<<endl;
cout<<" enrollment score"<<score<<endl;
}
protected:
char id[12];
char date[11];
float score;
};
int main()
{
Student stu("Mary",'F',19,"2020","20123",680);
stu.StuShow();
return 0;
}
说这行 strcpy(name,Name);有问题
|
-
最佳答案
查看完整内容
char name{11} 更改为char name[11]
|