鱼C论坛

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

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

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

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

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

x
I Like Mai Forever!
#include<iostream>
#include<string>
class Lovers
{
    friend class Others;
public:
    Lovers(std::string theName);
    void hug(Lovers *lovers);
    void hold_hands(Lovers *lovers);
    void mating(Lovers *lovers);
    void kiss(Lovers *lovers);
private:
    std::string name;
};

Lovers::Lovers(std::string theName)
{
    name=theName;
}

class Boyfriend:public Lovers
{
public:
    Boyfriend(std::string theName);
};
Boyfriend::Boyfriend(std::string theName):Lovers(theName)
{
}

class Girlfriend:public Lovers
{
public:
    Girlfriend(std::string theName);
};
Girlfriend::Girlfriend(std::string theName):Lovers(theName)
{
}


class Others
{
public:
    std::string name;
    Others(std::string theName);
    void mating(Lovers *lovers);
};
Others::Others(std::string theName)
{
    name=theName;
}
class Sexfriend:public Others
{
public:
    Sexfriend(std::string theName);
};
Sexfriend::Sexfriend(std::string theName):Others(theName)
{
}

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

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

int main()
{
    Boyfriend bf("Sakuta");
    Girlfriend gf("Mai");
    Others ntr("I");

    bf.hold_hands(&gf);
    ntr.mating(&gf);
    return 0;
}
第一次发学习笔记,不知道标题有没有违规哈:)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-10-3 10:48

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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