由买买提看人间百态

topics

全部话题 - 话题: bangwith
(共0页)
m*********n
发帖数: 28
1
来自主题: Programming版 - 该怎么设计这个类?
后面的补充想法是对的。给你个范例程序
struct SexOrgan {
};
struct Asshole : public SexOrgan {
};
struct Dick : public SexOrgan {
};
struct Pussy : public SexOrgan {
void Eat(Dick& dick) {
};
};
void B2B(Pussy& p0, Pussy& p1) {
}
struct HumanBeing {
virtual void BangWith(HumanBeing & that) {
// take off all clothes;
}
};
struct Female;
struct Male : public HumanBeing {
virtual void BangWith(HumanBeing& that) {
HumanBeing::BangWith(that);
Female* female = dynamic_cast阅读全帖
c*********e
发帖数: 16335
2
来自主题: Programming版 - 该怎么设计这个类?
HumanBeing 有3个子类:Male, Female, Gay。
你这个是用if...else把不同的子类分开,如果子类是Male,这么做;如果子类是Female,
这么做. 那么,如果再要加一个新的子类,Transgender,你的很多函数要重新写了,比
如下面这个BangWith()函数。况且,gay,可以是Male, or Female.
struct Female : public HumanBeing {
virtual void BangWith(HumanBeing& that) {
HumanBeing::BangWith(that);
Male* male = dynamic_cast (&that);
if (male) {
pussy->Eat(male->ShowStuff());
} else {
Female* female = dynamic_cast (&that);
if ... 阅读全帖
c*********e
发帖数: 16335
3
来自主题: Programming版 - 该怎么设计这个类?
en,感觉精华在这
virtual void BangWith(HumanBeing& that) {
HumanBeing::BangWith(that);
Male* male = dynamic_cast (&that);
if (male) {
...
} else {
...
(共0页)