#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;
}
组合
最新推荐文章于 2024-05-02 21:23:42 发布