commit 2025-08-18 00:18 edit ZCppMain/ZtCObjList.H : add ZtCExamObjList

This commit is contained in:
2025-08-18 00:25:49 +09:00
parent af60e817f3
commit a4c6342573
2 changed files with 162 additions and 3 deletions

View File

@ -2283,6 +2283,165 @@ namespace ZNsMain
/////////////////////////////////////////////////////////////////////////////*/
namespace ZNsExam
{
template<typename TDummy=void*> class ZtCExamObjList
{
public:
#ifndef _WIN
class CHelpObj
{
public:
CHelpObj()
{
}
CHelpObj(const CHelpObj& rhs)
{
cout<<"* CHelpObj(const CHelpObj& rhs)"<<endl;
}
public:
}; CHelpObj VO_CHelpObj; cout<<"VO_CHelpObj Ptr : "<<&VO_CHelpObj<<endl;
struct StFunctor
{
static void ShowElement(int ArgiValue){cout<<"#1 Value="<<ArgiValue<<endl;}
};
struct StFunctor2
{
static void ShowElement(int ArgiValue, CHelpObj)
{cout<<"#2 Value="<<ArgiValue<<", CHelpObj Addr=None"<<" With CHelpObj"<<endl;}
};
struct StFunctor3
{
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj)
{cout<<"#3 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Ref"<<endl;}
};
struct StFunctor4
{
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj)
{cout<<"#4 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj in Ptr"<<endl;}
};
struct StFunctor5
{
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj, CHelpObj& AR_CHelpObj2)
{cout<<"#5 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Ref 2"<<endl;}
};
struct StFunctor6
{
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj, CHelpObj AO_CHelpObj2)
{cout<<"#6 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Half Ref"<<endl;}
};
#endif //!defined(_WIN)
static int Main(int AI_ArgCnt=0, const char* APP_ArgVal[]=0)
{
using namespace std ;
using namespace ZNsMain;
typedef ZtCObjList<int> CObjList ;
typedef CObjList::IterEasy IterEasyL;
CObjList VO_CObjList;
VO_CObjList.AddTail(10);
VO_CObjList.AddTail(20);
VO_CObjList.AddTail(30);
VO_CObjList.AddTail(40);
IterEasyL VH_IterL = VO_CObjList.ItHEasy();
#ifdef _WIN
class CHelpObj
{
public:
CHelpObj()
{
}
CHelpObj(const CHelpObj& rhs)
{
cout<<"* CHelpObj(const CHelpObj& rhs)"<<endl;
}
public:
}; CHelpObj VO_CHelpObj; cout<<"VO_CHelpObj Ptr : "<<&VO_CHelpObj<<endl;
struct StFunctor
{
static void ShowElement(int ArgiValue){cout<<"#1 Value="<<ArgiValue<<endl;}
};
struct StFunctor2
{
static void ShowElement(int ArgiValue, CHelpObj)
{cout<<"#2 Value="<<ArgiValue<<", CHelpObj Addr=None"<<" With CHelpObj"<<endl;}
};
struct StFunctor3
{
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj)
{cout<<"#3 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Ref"<<endl;}
};
struct StFunctor4
{
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj)
{cout<<"#4 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj in Ptr"<<endl;}
};
struct StFunctor5
{
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj, CHelpObj& AR_CHelpObj2)
{cout<<"#5 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Ref 2"<<endl;}
};
struct StFunctor6
{
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj, CHelpObj AO_CHelpObj2)
{cout<<"#6 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Half Ref"<<endl;}
};
#endif //_WIN
cout<<endl<<"#### Show CObjList Element ####"<<endl<<endl;
VO_CObjList.IterElement(StFunctor ::ShowElement);
VO_CObjList.IterElement(StFunctor2::ShowElement, VO_CHelpObj );
VO_CObjList.IterElement(StFunctor3::ShowElement, ZftMCR(VO_CHelpObj) );
VO_CObjList.IterElement(StFunctor4::ShowElement, ZftMCP(VO_CHelpObj) );
VO_CObjList.IterElement(StFunctor5::ShowElement, ZftMCP(VO_CHelpObj), ZftMCP(VO_CHelpObj) );
VO_CObjList.IterElement(StFunctor6::ShowElement, ZftMCP(VO_CHelpObj), VO_CHelpObj );
/* 위 코드에서 ShowElement() 정의가 Main 함수 안에 있으면,
linux g++ 4.4.7 에서 컴파일 에러다. struct StFunctor1
등의 정의를 Main() 함수 바깥으로 빼면 된다.
*/
__for1(int, i, VO_CObjList.size())
{
cout<<i<<"th value="<<
VO_CObjList.ItD(VH_IterL)<<endl;
VO_CObjList.ItNext(VH_IterL); //////
}/*
__for1(int, i, VO_CObjList.size())*/
return 0;
}/*
static int Main(int AI_ArgCnt=0, const char* APP_ArgVal[]=0)*/
public:
};/*
template<typename TDummy=void*> class ZtCExamObjList*/
}/*
namespace ZNsExam*/
namespace ZNsType
{

View File

@ -661,7 +661,7 @@ namespace ZNsMain
namespace ZNsExam
{
template<typename TTypeInt=int> class ZtCSortIntList
template<typename TTypeInt=int> class ZtExamSortIntList
{
public:
@ -676,7 +676,7 @@ namespace ZNsMain
using namespace std; typedef ZNsMain::
ZtCObjList<TTypeInt, TTypeInt> CObjList ;
CObjList VO_CIntList; //////////////////////////
CObjList VO_CIntList; ///////////////////////////
VO_CIntList.AddTail(10); VO_CIntList.AddTail(1 );
VO_CIntList.AddTail(6 ); VO_CIntList.AddTail(4 );
@ -695,7 +695,7 @@ namespace ZNsMain
public:
};/*
template<typename TTypeInt=int> class ZtCSortIntList*/
template<typename TTypeInt=int> class ZtExamSortIntList*/
}/*
namespace ZNsExam*/