帮我看看这个编程哪里错了

来源:百度知道 编辑:UC知道 时间:2024/05/21 10:30:24
#include<iostream.h>
class student
{
char * name=new char; int age; char sex;
float English;
public:
student();
student(char *s, int a, char s, float score);
student(const student &st);
~student();
void set(char *s, int a, char s, float score);
void print();
};

student::student()
{
*name=''; sex=0;
age=0; English=0;
}
student::student(char *s, int a, char s, float score)
{
name=s; age=a;
sex=s; English=score;
}
student::student(const student &st)
{
student=st.student;
}
void student::set(char *s, int a, char s, float score)
{
return {*name,age,sex,English};

}
void student::print()
{
cout<<"name:"<<*name<<",age:"<<age<<&

#include <iostream.h>
#include <string.h>
class student
{
char * name;
int age;
char sex;
float English;
public:
student();
student(char *str, int a, char s, float score);
student(const student &st);
~student();
void set(char *str, int a, char s, float score);
void print();
};

student::student()
{
name = NULL;
sex='\0';
age=0;
English=0;
}
student::~student()
{
delete[] name;
}
student::student(char *str, int a, char s, float score)
{
name = new char[strlen(str)+1];
strcpy(name, str);
age=a;
sex=s;
English=score;
}
student::student(const student &st)
{
name = new char[strlen(st.name)+1];
strcpy(name, st.name);
age = st.age;
sex = st.sex;
English = st.English;
}
void student::set(char *str, int a, char s, float sc