mshd.net
当前位置:首页 >> C++问题,构造一个学生类 >>

C++问题,构造一个学生类

#include #include /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; /* 学生的基本信息 */ struct st_info{ int id; char name[30]; double grade; }; /* 创建一...

//xx.h#include#includeusing namespace std;class student{private:string name; //姓名string sex; //性别int age; //年龄string ID; //学号string department; //系别double mathScore; //数学成绩double englishScore; //英语成绩double phy...

#include #include using namespace std; class CStudent { public: CStudent(); float sum(); float average(); void print_inf(); int get_reg_num(); void set_stu_inf(int x,char* na,float s,float y,float j); private: int no;//学号 cha...

#include #include using namespace std; class Student { private: string name; string code; int age; public: Student() { name = ""; //其实这里不需要初始化,因为string定义的变量已经初始化为空了 code = ""; age = 0; } Student(string...

//CStudent.hcalss CStudent{ public: long ID; char* pchName; float fWeight; public: CStudent();//构造 ~CStudent(); //析构}; // CStudent.cpp#include "iostream"CStudent();{ ID = 0; pchName = NULL; fWeight = 0.0f; } ~CStudent(){};...

定义一个学生类,里面包含了学生的姓名、四科成绩和平均成绩的成员变量,计算平均分的成员函数。在学生类的构造函数里对学生的姓名和成绩做初始化。然后你实例化5个学生变量就可以了。 CStudent { private: char mName[20]; float mScore[4]; pu...

#define _CRT_SECURE_NO_WARNINGS#include #include using namespace std;//创建学生类class student{public:student(){} //构造函数void insertInfo(){cout name >> num >> qzScore >> qmScore >> psScore;countScore = psScore*0.4 + 0.2*qzSc...

#include #include using namespace std; class Student { private: string SName; string SNo; string SScore[10]; public : void init(); void print(); }; void Student::init() { coutthis->SName; coutthis->SNo; coutSScore[i]; } } void ...

#include #include using namespace std;class Student{public: // 带参数的构造函数初始化对象 Student(int id, string name, double score) : id(id), name(name), score(score) { count++; total+=score; } // 修改分数成员函数 void ChangeS...

class CStudent {public: CStudent(){ name = new char[100]; } CStudent(CStudent& S){ name = new char[100]; name = S.GetName(); } ~CStudent(){ delete name; } char* GetName() { return name; } void SetName(char n[100]){ name = n; }p...

网站首页 | 网站地图
All rights reserved Powered by www.mshd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com