组合
来源:互联网 发布:开淘宝店要网银吗 编辑:程序博客网 时间:2024/04/29 21:32
#include <iostream>using namespace std;class eye{public:void look (void){}//看};class nouse{public:void smell (void){}//闻};class mouth{public:void eat (void ){}//吃};class head{private://组合eye Look;nouse Smell;mouth Eat;public:void llook (){Look.look ();}void eeat(){Eat.eat ();}void ssmell (){Smell.smell ();}};int main(){head T1;T1.eeat ();// 开始报错 是因为 上面的 每个 public函数 都没有 {}// public:// void eat (void); error编译 失败。// void eat ()//{// }right 编译通过return 0;}