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

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

class Students{ private : long number; double grade1, grade2, grade3; char address[100]; char contect[50]; public : void setNumber(long number); void setGrade1(Double grade1); void setGrade2(Double grade2); void setGrade3(Doubl...

#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; }; /* 创建一...

#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{public: // 带参数的构造函数初始化对象 Student(int id, string name, double score) : id(id), name(name), score(score) { count++; total+=score; } // 修改分数成员函数 void ChangeS...

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

#include #include using namespace std;class student{public: static int count; student(){++count;} student(string ID="",string name="",int sex=0,int grade=0): m_ID(ID),m_name(name),m_sex(sex),m_grade(grade){++count;} ~student(){...

#include #include using namespace std;class STUDENT{private:string sid;//IDstring sname;//姓名string gender;//性别string professional;//专业public:void setSid(string sid){this->sid = sid;}void setSname(string sname){this->sname...

public class Student{ private: string name; char sex; int age; public: Student(string n, char s, int a) { name = n; sex = s; age = a; } void setName(string n) { name = n; } void setAge(int a) { age = a; } int getAge() { return ...

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

teacher(s);上边这个语句有问题。teacher是一个类,没有实体。另外,构造函数只有在新建对象时才可以使用。 你可以这样: teacher t2(s);t2.display();

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