学生类2(练习题)


#include  
#include
using namespace std;
class Student{
        public:
        Student();
        Student(string,string,char,int,double,double,double);
    double average();
        void setStudent(string a_name,string n,char s,int a,double c,double m,double e){
        name=a_name;
        num=n;
        sex=s;
        age=a;
        chinese=c;
        math=m;
        english=e;
        }
        string geta_name(){return name;}
        string getn(){return num;}
        char gets(){return sex;}
        int geta(){return age;}        
        double getc(){return chinese;}
        double getm(){return math;}
        double gete(){return english;}                        
        ~Student()
        {cout<<"Destructor called."<
        void display()
        {cout<
        private:
        string name;string num;char sex;int age;double chinese;double math;double english;
        };
        Student::Student()
        {chinese=0;math=0;english=0;}
        Student::Student(string a_name,string n,char s,int a,double c,double m,double e):name(a_name),num(n),sex(s),age(a),chinese(c),math(m),english(e){        
        cout<<"Constructor called."<
    double Student::average()
        {return        (chinese+math+english)/3;}                
        int main()
        {
        string name;string num;char sex;int age;double chinese;double math;double english;
        Student r;
        cin>>name>>num>>sex>>age>>chinese>>math>>english;
        r.setStudent(name,num,sex,age,chinese,math,english);
        r.display();
        cout<
    return 0;
}

你可能感兴趣的:(学生类2(练习题))