Cpp クラス 継承 新しいページはコチラ
提供: yonewiki
(→クラス 継承) |
|||
| 32行: | 32行: | ||
int m_iBaseMoney; | int m_iBaseMoney; | ||
int m_iBaseMonth; | int m_iBaseMonth; | ||
| − | |||
int m_fiBaseSumMoney(); | int m_fiBaseSumMoney(); | ||
public: | public: | ||
| + | CBaseInheritance(); | ||
CBaseInheritance(int iArgBaseMoney, int iArgBaseMonth); | CBaseInheritance(int iArgBaseMoney, int iArgBaseMonth); | ||
~CBaseInheritance(); | ~CBaseInheritance(); | ||
| 47行: | 47行: | ||
#include <cstdio> | #include <cstdio> | ||
#include "BaseInheritance.h" | #include "BaseInheritance.h" | ||
| + | |||
| + | CBaseInheritance::CBaseInheritance() { | ||
| + | printf("Constructor:CBaseInheritance()\n"); | ||
| + | } | ||
CBaseInheritance::CBaseInheritance(int iArgBaseMoney, int iArgBaseMonth) { | CBaseInheritance::CBaseInheritance(int iArgBaseMoney, int iArgBaseMonth) { | ||
m_iBaseMoney = iArgBaseMoney; | m_iBaseMoney = iArgBaseMoney; | ||
m_iBaseMonth = iArgBaseMonth; | m_iBaseMonth = iArgBaseMonth; | ||
| − | printf("Constructor:CBaseInheritance\n"); | + | printf("Constructor:CBaseInheritance(int,int)\n"); |
} | } | ||
CBaseInheritance::~CBaseInheritance() { | CBaseInheritance::~CBaseInheritance() { | ||
| − | printf("Destructor:~CBaseInheritance\n"); | + | printf("Destructor:~CBaseInheritance()\n"); |
} | } | ||
void CBaseInheritance::m_fvBaseDispValue() { | void CBaseInheritance::m_fvBaseDispValue() { | ||
int iSumMoney = m_fiBaseSumMoney(); | int iSumMoney = m_fiBaseSumMoney(); | ||
| − | printf(" | + | printf("BaseMoney=%d\n", iSumMoney); |
} | } | ||
int CBaseInheritance::m_fiBaseSumMoney() { | int CBaseInheritance::m_fiBaseSumMoney() { | ||
| 95行: | 99行: | ||
<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 上 右 下 左--> | ||
<syntaxhighlight2 lang="cpp" line> | <syntaxhighlight2 lang="cpp" line> | ||
| − | # | + | #ifndef __DERIVEINHERITANCE_H_YONET__ |
| − | # | + | #define __DERIVEINHERITANCE_H_YONET__ |
#if _MSC_VER > 1000 | #if _MSC_VER > 1000 | ||
#pragma once | #pragma once | ||
#endif | #endif | ||
| + | #include "BaseInheritance.h" | ||
| − | class CDeriveInheritance:public CBaseInheritance{ | + | class CDeriveInheritance :public CBaseInheritance { |
private: | private: | ||
| + | int m_iOptionMoney; | ||
int m_iDeriveMoney; | int m_iDeriveMoney; | ||
| + | public: | ||
CDeriveInheritance(int iArgDeriveMoney, int iArgDeriveMonth, int iArgOptionMoney); | CDeriveInheritance(int iArgDeriveMoney, int iArgDeriveMonth, int iArgOptionMoney); | ||
~CDeriveInheritance(); | ~CDeriveInheritance(); | ||
| − | |||
void m_fvDeriveDispValue(); | void m_fvDeriveDispValue(); | ||
int m_fiDeriveSumMoney(); | int m_fiDeriveSumMoney(); | ||