#include <iostream>
using namespace std;
class Student
{
private:
char *name;
char *stu_no;
float score;
public:
Student(char *name1,char *stu_no,float score1);
~Student();
void modify(float score1);
void show();
};
#include "student.h"
Student::Student(char *name1,char *stu_no1,float score1)
{
name = new char[strlen(name1)+1];
strcpy(name,name1);
stu_no = new char[strlen(stu_no1)+1];
strcpy(stu_no,stu_no1);
score = score1;
}
Student::~Student()
{
delete []name;
delete []stu_no;
}
void Student::modify(float score1)
{
score = score1;
}
void Student::show()
{
cout<<"name: "<<name<<endl;
cout<<"stu_no: "<<stu_no<<endl;
cout<<"score: "<<score<<endl;
}
#include "student.h"
int main()
{
Student stu1("ChangRui","201601028",96);
stu1.show();
stu1.modify(95);
stu1.show();
return 0;
}