4,在本章第2.6.2(题目错误)节中给出了包含类定义的头文件student.h,包含成员函数定义的源文件student.cpp以及包含主函数的源文件main.cpp。请完善该程序,在类中增加一个对数

来源:互联网 发布:腾讯出品的软件 编辑:程序博客网 时间:2024/04/30 04:35
Main.cpp#include #include"student.h"using namespace std;int main(){Student stud;cout<<"请按 学号 名字 性别 输入\n";stud.sex_value();stud.display();return 0;}Student.cpp#include#include"student.h"void Student::display(){cout<<"num:"<<num<<endl;cout<<"name:"<<name<<endl;cout<<"sex:"<<sex<>num>>name>>sex;}Student.h#include using namespace std;class Student{public:void display();void sex_value();private:int num;string name;char sex;};
0 1
原创粉丝点击