码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • c++day5


    1. class Sofa
    2. {
    3. protected:
    4. string sit;
    5. public:
    6. Sofa()
    7. {
    8. cout << "沙发无参构造" << endl;
    9. }
    10. Sofa(string s):sit(s)
    11. {
    12. cout << "沙发有参构造" << endl;
    13. }
    14. Sofa(const Sofa &other):sit(other.sit)
    15. {
    16. cout << "沙发拷贝构造" << endl;
    17. }
    18. Sofa &operator=(const Sofa &other)
    19. {
    20. cout << "沙发拷贝赋值" << endl;
    21. if(this!= &other)
    22. {
    23. sit = other.sit;
    24. }
    25. return *this;
    26. }
    27. void show()
    28. {
    29. cout << "sit=" << sit <
    30. }
    31. };
    32. class Bed
    33. {
    34. protected:
    35. string sleep;
    36. public:
    37. Bed()
    38. {
    39. cout << "床无参构造" << endl;
    40. }
    41. Bed(string s):sleep(s)
    42. {
    43. cout << "床有参构造" << endl;
    44. }
    45. Bed(const Bed &other):sleep(other.sleep)
    46. {
    47. cout << "床拷贝构造" << endl;
    48. }
    49. Bed &operator=(const Bed &other)
    50. {
    51. cout << "床拷贝赋值" << endl;
    52. if(this!= &other)
    53. {
    54. sleep = other.sleep;
    55. }
    56. return *this;
    57. }
    58. void show()
    59. {
    60. cout << "sleep=" << sleep <
    61. }
    62. };
    63. class Sofa_bed:public Sofa,protected Bed
    64. {
    65. private:
    66. string down;
    67. public:
    68. Sofa_bed()
    69. {
    70. cout << "床和沙发的无参构造" << endl;
    71. }
    72. Sofa_bed(string a,string b,string c):Sofa(a),Bed(b),down(c)
    73. {
    74. cout << "床和沙发的有参构造" << endl;
    75. }
    76. Sofa_bed(const Sofa_bed &other):Sofa(other),Bed(other),down(other.down)
    77. {
    78. cout << "床和沙发的拷贝构造" << endl;
    79. }
    80. Sofa_bed &operator=(const Sofa_bed &other)
    81. {
    82. cout << "床和沙发的拷贝赋值" << endl;
    83. if(this!= &other)
    84. {
    85. down = other.down;
    86. Sofa::operator = (other);
    87. Bed::operator = (other);
    88. }
    89. return *this;
    90. }
    91. void show()
    92. {
    93. cout << "多继承子类" << endl;
    94. cout << "down=" << down << endl;
    95. cout << "sit=" << sit << endl;
    96. cout << "sleep=" << sleep << endl;
    97. }
    98. };

  • 相关阅读:
    log4j2同步日志引发的性能问题 | 京东物流技术团队
    【名词解释】concolic testing和instrumentation
    第六十天 周期总结及下周期计划
    (13.3)Latex参考文献引用及常规引用
    (CVPR 2019) PointConv: Deep Convolutional Networks on 3D Point Clouds
    Redis缓存穿透、缓存击穿、缓存雪崩详解
    redis-5.0.8主从集群搭建、不重启修改配置文件
    软件测试分析流程及输出项包括哪些内容?
    TDengine 3.0 数据订阅功能的“独家”使用经验,只此一份!
    计算机网络介绍
  • 原文地址:https://blog.csdn.net/m0_73912044/article/details/133777113
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号