📄 soln9_2.cpp
字号:
/*
It is reasonable to derive a CHawk class from CBird, but not COStrich because an ostrich cannot fly.
A better hierarchy of classes to represent birds would allow flightless birds such as ostriches and penguins
to be represented by a separate class. The hierarchy below allows that.
*/
class CBird
{
protected:
int wingSpan;
int eggSize;
};
class CFlightlessBird: public CBird
{
};
class CFlyingBird: public CBird
{
protected:
int airSpeed;
int altitude;
public:
virtual void fly( {altitude = 100;
};
/*
Now CHawk can be derived from CFlyingBird and COstrich can be derived from CFlightlessBird
and the both share the common base class CBird.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -