在C++中,派生类中怎样用构造函数(涉及字符串的)

来源:百度知道 编辑:UC知道 时间:2024/05/17 09:53:10
#include<iostream>
#include<string>
using namespace std;
class student //基类
{
public:
student(char name[100],char sex[20],char grade[200],long int num,double math,double chinese);
virtual void display();
protected:
char name[100];
char sex[20];
char grade[200];
long int num;
double math;
double chinese;
int subjectnum;
double aver;
};

student::student(char name[100],char sex[20],char grade[200],long int num,double math,double chinese)
{
strcpy(this->name ,name);
strcpy(this->sex ,sex);
strcpy(this->grade ,grade);
this->num =num;
this->math =math;
this->chinese =chinese;
}

void student::display ()
{
cout<<name<<"\t"<<sex<<"\t"<<grade<<"t"<<num<<"\t"<<math<<"\t&quo

collegestudent(char college[200],char major[100],double english,double clanguage,char name[100],char sex[20],char grade[200],long int num,double math,double chinese):student(name,sex,grade,num,math,chinese)
//student前三个参数是char[],而你传的是char类型

实例化对象时的问题吧