Cpp クラス const 新しいページはコチラ
提供: yonewiki
(→クラス const) |
(→クラス const) |
||
113行: | 113行: | ||
CConst001::~CConst001(void) | CConst001::~CConst001(void) | ||
{ | { | ||
+ | } | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | sample_main.cpp | ||
+ | <syntaxhighlight lang="cpp" line start="1"> | ||
+ | #include "stdafx.h" | ||
+ | #include "Const001.h" | ||
+ | |||
+ | int _tmain(int argc, _TCHAR* argv[]) | ||
+ | { | ||
+ | CConst001* CConst001_Instance = new CConst001; | ||
+ | CConst001_Instance->mfpub_Set_m_nValue(1000); | ||
+ | //CConst001_Instance->mpub_constnValue = 1000;★constメンバ変数の呼び出しは出来ない。 | ||
+ | |||
+ | const CConst001* CConst001_constInstance = new CConst001; | ||
+ | CConst001_constInstance->mfpubconst_Get_m_nValue(); | ||
+ | //CConst001_constInstance->mfpub_Get_m_nValue();★const メンバ関数でないと呼べない。 | ||
+ | |||
+ | return 0; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |