Cpp クラス 継承 新しいページはコチラ
提供: yonewiki
(→クラス 継承) |
(→クラス 継承) |
||
83行: | 83行: | ||
− | + | でも、勉強だし、簡単なので、やってみましょう。まずは派生させたヘッダファイルを作ります。 | |
+ | |||
<span style="color: #ffffff; background-color: #555555; padding: 0px 5px 0px 5px; display: inline-block;">cpp <span>(</span>DeriveInheritance.h<span>)</span><!-- padding 上 右 下 左--> | <span style="color: #ffffff; background-color: #555555; padding: 0px 5px 0px 5px; display: inline-block;">cpp <span>(</span>DeriveInheritance.h<span>)</span><!-- padding 上 右 下 左--> | ||
93行: | 94行: | ||
#endif | #endif | ||
− | class CDeriveInheritance | + | class CDeriveInheritance:CBaseInheritance{ |
private: | private: | ||
int m_iDeriveMoney; | int m_iDeriveMoney; | ||
− | void CDeriveInheritance(int iArgDeriveMoney, int iArgDeriveMonth); | + | void CDeriveInheritance(int iArgDeriveMoney, int iArgDeriveMonth, int iOptionManey); |
void ~CDeriveInheritance(); | void ~CDeriveInheritance(); | ||
public: | public: | ||
− | void | + | void m_fvDeriveDispValue(); |
int m_fiDeriveSumMoney(); | int m_fiDeriveSumMoney(); | ||
}; | }; | ||
#endif | #endif | ||
</syntaxhighlight2> | </syntaxhighlight2> | ||
+ | |||
+ | |||
+ | こんな感じの関数を定義してみようと思います。この中で新しい表記は一か所だけです。1行目の | ||
+ | |||
+ | <syntaxhighlight2 lang="cpp"> | ||
+ | class CDeriveInheritance:CBaseInheritance{ | ||
+ | </syntaxhighlight2> | ||
+ | |||
+ | この部分が継承を定義している部分です。:の後ろが基底クラス名です。:の前は派生クラス名ということになります。 | ||
+ | |||