64,648
社区成员
发帖
与我相关
我的任务
分享
tom:
hungry
...
dididi
jack:
delicious
ohyeah
dididi
hello
rose:
kfc
ohyeahohyeah
hello
apple
请按任意键继续. . .
class after70s
{
public:
virtual void eat(){cout <<"\thungry" <<endl;}
virtual void sex(){cout <<"\t..." <<endl;}
void bp(){cout <<"\tdididi" <<endl;}
};
class after80s: public after70s
{
public:
void eat(){cout <<"\tdelicious" <<endl;}
void sex(){cout <<"\tohyeah" <<endl;}
void cell(){cout <<"\thello" <<endl;}
};
class after90s: private after80s
{
public:
void eat(){cout <<"\tkfc" <<endl;}
void sex(){cout <<"\tohyeahohyeah" <<endl;}
using after80s::cell;
void iphone(){cout <<"\tapple" <<endl;}
};
void live(after70s *someone)
{
someone->eat();
someone->sex();
}
int main()
{
cout <<endl <<"tom:" <<endl;
after70s tom;
live(&tom);
tom.bp();
cout <<endl <<"jack:" <<endl;
after80s jack;
live(&jack);
jack.bp();
jack.cell();
cout <<endl <<"rose:" <<endl;
after90s rose;
live((after70s*)&rose);
//rose.bp(); // 90后不知道bp机
rose.cell();
rose.iphone();
return 0;
}