鱼C论坛

 找回密码
 立即注册
查看: 2794|回复: 0

[技术交流] C++快速入门 Link Start! 第二十讲 绿色真是一种和谐的颜色🍏

[复制链接]
发表于 2019-3-8 15:06:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
I Like Mai Forever!
  1. #include<iostream>
  2. #include<string>
  3. class Lovers
  4. {
  5.     friend class Others;
  6. public:
  7.     Lovers(std::string theName);
  8.     void hug(Lovers *lovers);
  9.     void hold_hands(Lovers *lovers);
  10.     void mating(Lovers *lovers);
  11.     void kiss(Lovers *lovers);
  12. private:
  13.     std::string name;
  14. };

  15. Lovers::Lovers(std::string theName)
  16. {
  17.     name=theName;
  18. }

  19. class Boyfriend:public Lovers
  20. {
  21. public:
  22.     Boyfriend(std::string theName);
  23. };
  24. Boyfriend::Boyfriend(std::string theName):Lovers(theName)
  25. {
  26. }

  27. class Girlfriend:public Lovers
  28. {
  29. public:
  30.     Girlfriend(std::string theName);
  31. };
  32. Girlfriend::Girlfriend(std::string theName):Lovers(theName)
  33. {
  34. }


  35. class Others
  36. {
  37. public:
  38.     std::string name;
  39.     Others(std::string theName);
  40.     void mating(Lovers *lovers);
  41. };
  42. Others::Others(std::string theName)
  43. {
  44.     name=theName;
  45. }
  46. class Sexfriend:public Others
  47. {
  48. public:
  49.     Sexfriend(std::string theName);
  50. };
  51. Sexfriend::Sexfriend(std::string theName):Others(theName)
  52. {
  53. }

  54. void Lovers::hold_hands(Lovers *lovers)
  55. {
  56.     std::cout<<name<<" hold hands with "<<lovers->name<<std::endl;
  57. }

  58. void Others::mating(Lovers *lovers)
  59. {
  60.     std::cout<<name<<" mating with "<<lovers->name<<std::endl;
  61. }

  62. int main()
  63. {
  64.     Boyfriend bf("Sakuta");
  65.     Girlfriend gf("Mai");
  66.     Others ntr("I");

  67.     bf.hold_hands(&gf);
  68.     ntr.mating(&gf);
  69.     return 0;
  70. }
复制代码

第一次发学习笔记,不知道标题有没有违规哈:)
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-19 07:07

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表