Cpp クラス 仮想関数 新しいページはコチラ
提供: yonewiki
(→クラス 仮想関数) |
(→クラス 仮想関数) |
||
| 22行: | 22行: | ||
<span style="color: #ffffff; background-color: #555555; padding: 0px 5px 0px 5px; display: inline-block;">cpp <span>(</span>基底クラス BaseInheritance.h<span>)</span><!-- padding 上 右 下 左--> | <span style="color: #ffffff; background-color: #555555; padding: 0px 5px 0px 5px; display: inline-block;">cpp <span>(</span>基底クラス BaseInheritance.h<span>)</span><!-- padding 上 右 下 左--> | ||
<syntaxhighlight2 lang="cpp" line> | <syntaxhighlight2 lang="cpp" line> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
#ifndef __BASEINHERITANCE_H_YONET__ | #ifndef __BASEINHERITANCE_H_YONET__ | ||
#define __BASEINHERITANCE_H_YONET__ | #define __BASEINHERITANCE_H_YONET__ | ||
| 52行: | 45行: | ||
で、まずは、基底クラスとしての、オプション明細つきとして、Option="None"と表示する以下のようなプログラムとしてみます。 | で、まずは、基底クラスとしての、オプション明細つきとして、Option="None"と表示する以下のようなプログラムとしてみます。 | ||
| + | <span style="color: #ffffff; background-color: #555555; padding: 0px 5px 0px 5px; display: inline-block;">cpp <span>(</span>基底クラス BaseInheritance.cpp<span>)</span><!-- padding 上 右 下 左--> | ||
| + | <syntaxhighlight2 lang="cpp" line start=100> | ||
| + | #include "pch.h" | ||
| + | #include "BaseInheritance.h" | ||
| + | CBaseInheritance::CBaseInheritance() { | ||
| + | printf("Constructor:CBaseInheritance()\n"); | ||
| + | } | ||
| + | |||
| + | CBaseInheritance::CBaseInheritance(int iArgBaseMoney, int iArgBaseMonth) | ||
| + | :m_iBaseMoney(iArgBaseMoney) | ||
| + | ,m_iBaseMonth(iArgBaseMonth) | ||
| + | ,m_iMoney(0) { | ||
| + | printf("Constructor:CBaseInheritance(int,int)\n"); | ||
| + | } | ||
| + | |||
| + | CBaseInheritance::~CBaseInheritance() { | ||
| + | printf("Destructor:~CBaseInheritance()\n"); | ||
| + | } | ||
| + | |||
| + | int CBaseInheritance::mf_iBaseSumMoney() { | ||
| + | m_iMoney = m_iBaseMoney * m_iBaseMonth; | ||
| + | return m_iMoney; | ||
| + | } | ||
| + | |||
| + | void CBaseInheritance::mfVirtual_vDispValue() { | ||
| + | int iSumMoney = mf_iBaseSumMoney(); | ||
| + | printf("BaseMoney=%d, option=\"none\" total=%d\n", iSumMoney,m_iMoney); | ||
| + | } | ||
| + | |||
| + | void CBaseInheritance::mf_vBaseDispValue() { | ||
| + | int iSumMoney = m_iBaseMoney * m_iBaseMonth; | ||
| + | printf("BaseMoney=%d, total=%d\n", iSumMoney, m_iMoney); | ||
| + | } | ||
| + | </syntaxhighlight2> | ||
[[C PlusPlus#C++からの技術|C++]]に戻る | [[C PlusPlus#C++からの技術|C++]]に戻る | ||