第三天练习(部分)

//student.h

#pragma once

#include<string>

#include<iostream>

using namespace std;

class student

{

public:

student(void);

~student(void);

void setValues(int n,string str,char c);

void display();

protected:

int num;string name;

char sex;

};

//student.cpp

#include"student.h"

using namespace std;

student::student(void){}

student::~student(void){}

void student::setValues(int n,string str,char c)

{num=n;name=str;sex=c;}

void student::display()

{

cout<<num<<""<<name<<""<<sex<<endl;

 

 

 

}

//postgraduent.h

#include"student.h"

class postgraduent:public student

{

public:

postgraduent(void);

~postgraduent(void);

void setAdvisor(string str)

{advisor=str;}

string getAdvisor(){return advisor;}

private:

string advisor;

};

 

//postgraduent.cpp

#include "postgraduent.h"

postgraduent::postgraduent(void)

{

}

postgraduent::~postgraduent(void)

{

}

//main.cpp

#include"postgraduent.h"

void main()

{

postgraduent xq;

xq.setValues(1122,"Xiao Qiang",'M');

xq.getAdvisor("Prof.Zhu");

xq.display();

cout<<"Advisor:"<<xq.getAdvisor()<<endl;

 

 

 

 

 

 

 

 

}

 

posted @   KuanDong24  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 【杂谈】分布式事务——高大上的无用知识?
点击右上角即可分享
微信分享提示