当前位置: 首页 > article >正文

4月23日作业

 

#include <iostream>
#include <cstring>
using namespace std;
 
class Student   //学生类
{
private:
    string name;   //姓名
    int year;      //年龄
    double sorce;  //分数
public:
    Student (){}    //无参构造
    Student(string a,int b,double c):name(a),year(b),sorce(c){} //有参构造
    ~Student() {}    //析构函数
    void show()
    {
        cout<<"student.name="<<name<<endl;
        cout<<"student.year="<<year<<endl;
        cout<<"student.sorce="<<sorce<<endl;
    }
     friend  class Student_cadres;    //设为学生干部类的友元
};
 
class Party  //党员类
{
private:
    string huodong;   //党组织活动
    string zuzhi;      //组织
public:
    Party (){}    //无参构造
    Party(string a,string b):huodong(a),zuzhi(b){} //有参构造
    ~Party(){}                 //析构函数
    void show()
    {
        cout<<"party.huodong="<<huodong<<endl;
        cout<<"party.zuzhi="<<zuzhi<<endl;
    }
     friend  class Student_cadres;     //设为学生干部类的友元
};
 
class Student_cadres:public Student,public Party
{
private:
    string position;  //职位
 
public:
    Student_cadres (){}    //无参构造
   Student_cadres(string name,int year,double sorce,string huodong, string zuzhi,string f):Student(name,year,sorce),Party(huodong,zuzhi),position(f){} //有参构造
    ~Student_cadres() {}                          //析构函数
     void show();   //声明学生干部类的show函数
 
};
void Student_cadres::show()    //执行学生干部类的show函数
{
    cout<<"student.name="<<name<<endl;
    cout<<"student.year="<<year<<endl;
    cout<<"student.sorce="<<sorce<<endl;
    cout<<"party.huodong="<<huodong<<endl;
    cout<<"party.zuzhi="<<zuzhi<<endl;
    cout<<"student_cadres.position="<<position<<endl;
}
 
int main()
{
    Student_cadres s1("zhangsan",18,98.5,"laoniangongyu","shaoxianduiyuan","laoda");
    s1.show();
 
    return 0;
}

http://www.kler.cn/news/16515.html

相关文章:

  • 年薪40万程序员辞职炒股,把一年工资亏光了,得了抑郁症,太惨了
  • 为什么越来越多的企业选择云计算?—分析云计算的优势和未来发展趋势
  • ​力扣解法汇总2404. 出现最频繁的偶数元素
  • 【华为机试】HJ1 字符串最后一个单词的长度
  • 【Vue面试题】vue组件之间如何传值通信
  • pytest - Getting Start
  • 8个免费使用ChatGPT网站,部分可使用gpt4
  • 如何将 github pages 迁移到 vercel 上托管
  • C# ref和out用法和区别
  • 【MySQL入门指南】主键与唯一键的使用与区别
  • 华为OD机试 - 日志首次上报最多积分(Python)
  • CTF ASCII码 密码解密题 简单
  • 《*** 法治思想学习纲要》学习辅导
  • Windows环境安装Elasticsearch和Kibana
  • 模式识别是什么意思
  • 武忠祥老师每日一题||不定积分基础训练(五)
  • RabbitMQ 发布订阅模式,routing路由模式,topic模式
  • 2023-5-2面试题学习
  • 746. 使用最小花费爬楼梯
  • Cell:癌症研究的下一个问题是什么?
  • 大学生学java编程的就业前景怎么样?我来聊聊自己的见解
  • 通过Python的PIL库给图片添加文本水印
  • 【网络协议详解】——GNS3的使用(学习笔记)
  • 计算机网络笔记:TCP协议 和UDP协议(传输层)
  • ChatGPT调教指南(中文)
  • 回到大学时光,我想对当时的自己说些什么
  • DDD系列:四、领域层设计规范
  • 存储资源调优技术——SmartThin智能精简配置技术
  • C++动态规划模板汇总大全
  • STM32物联网实战开发(4)——基本定时器