A.sir 发表于 2019-3-8 15:06:30

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

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;
}
第一次发学习笔记,不知道标题有没有违规哈:)
页: [1]
查看完整版本: C++快速入门 Link Start! 第二十讲 绿色真是一种和谐的颜色&#127823;