Cpp クラス 継承 新しいページはコチラ
提供: yonewiki
(→クラス 継承) |
(→クラス 継承) |
||
138行: | 138行: | ||
− | + | =メンバ関数の利用用途= | |
+ | *m_fvDeriveDispValue():派生した方法での合計金額の中身を知るための関数 | ||
+ | *m_fiDeriveSumMoney(): 合計金額を取り出す関数 | ||
+ | という感じです。 | ||
+ | そうすると、派生したクラスのプログラム部分のファイルの中身は以下のようになります。 | ||
+ | |||
+ | <span style="color: #ffffff; background-color: #555555; padding: 0px 5px 0px 5px; display: inline-block;">cpp <span>(</span>DeriveInheritance.cpp<span>)</span><!-- padding 上 右 下 左--> | ||
+ | <syntaxhighlight2 lang="cpp" line start=600> | ||
+ | #include <cstdio> | ||
+ | #include "DeriveInheritance.h" | ||
+ | |||
+ | CDeriveInheritance::CDeriveInheritance(int iArgDeriveMoney, int iArgDeriveMonth, int iArgOptionMoney) { | ||
+ | printf("Constructer:CDeriveInheritance(int,int,int)\n"); | ||
+ | m_iBaseMoney = iArgDeriveMoney; | ||
+ | m_iBaseMonth = iArgDeriveMonth; | ||
+ | m_iOptionMoney = iArgOptionMoney; | ||
+ | } | ||
+ | |||
+ | CDeriveInheritance::~CDeriveInheritance() { | ||
+ | printf("Destructer:~CDeriveInheritance()\n"); | ||
+ | } | ||
+ | |||
+ | void CDeriveInheritance::m_fvDeriveDispValue() { | ||
+ | int iSumMoney = m_fiDeriveSumMoney(); | ||
+ | printf("DeriveMoney=%d\n", iSumMoney); | ||
+ | |||
+ | } | ||
+ | |||
+ | int CDeriveInheritance::m_fiDeriveSumMoney() { | ||
+ | return m_fiBaseSumMoney() + m_iOptionMoney; | ||
+ | } | ||
+ | |||
+ | |||
+ | </syntaxhighlight2> | ||
[[C PlusPlus#C++からの技術|C++]]に戻る | [[C PlusPlus#C++からの技術|C++]]に戻る |