219 lines
7.5 KiB
C++
219 lines
7.5 KiB
C++
|
|
|||
|
|
|||
|
#include <iostream>
|
|||
|
#include "ZCppMain/ZtCArray.H"
|
|||
|
|
|||
|
|
|||
|
using namespace std;
|
|||
|
|
|||
|
|
|||
|
namespace ZNsMain
|
|||
|
{
|
|||
|
|
|||
|
namespace ZNsExam
|
|||
|
{
|
|||
|
|
|||
|
template<typename TDummy=void*> class ZtCExamArray
|
|||
|
{
|
|||
|
public:
|
|||
|
|
|||
|
#ifndef _WIN
|
|||
|
|
|||
|
class CHelpObj
|
|||
|
{
|
|||
|
public:
|
|||
|
|
|||
|
CHelpObj()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
CHelpObj(const CHelpObj& rhs)
|
|||
|
{
|
|||
|
cout<<"* CHelpObj(const CHelpObj& rhs)"<<endl;
|
|||
|
}
|
|||
|
|
|||
|
public:
|
|||
|
};
|
|||
|
|
|||
|
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 //#ifndef _WIN
|
|||
|
|
|||
|
|
|||
|
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)
|
|||
|
{
|
|||
|
using namespace std ;
|
|||
|
using namespace ZNsMain;
|
|||
|
|
|||
|
typedef ZtCArray<int> CArray ;
|
|||
|
typedef CArray::IterEasy IterEasy;
|
|||
|
|
|||
|
|
|||
|
CArray VO_Array;
|
|||
|
|
|||
|
VO_Array.AddTail(10);
|
|||
|
VO_Array.AddTail(20);
|
|||
|
VO_Array.AddTail(30);
|
|||
|
VO_Array.AddTail(40);
|
|||
|
|
|||
|
|
|||
|
#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;}
|
|||
|
};
|
|||
|
#else // _WIN
|
|||
|
CHelpObj VO_CHelpObj;
|
|||
|
|
|||
|
cout<<"VO_CHelpObj Ptr : "<<&VO_CHelpObj<<endl;
|
|||
|
#endif //!_WIN
|
|||
|
|
|||
|
VO_Array.IterElement(StFunctor ::ShowElement);
|
|||
|
VO_Array.IterElement(StFunctor2::ShowElement, VO_CHelpObj );
|
|||
|
VO_Array.IterElement(StFunctor3::ShowElement, ZftMCR(VO_CHelpObj) );
|
|||
|
VO_Array.IterElement(StFunctor4::ShowElement, ZftMCP(VO_CHelpObj) );
|
|||
|
VO_Array.IterElement(StFunctor5::ShowElement, ZftMCP(VO_CHelpObj), ZftMCP(VO_CHelpObj) );
|
|||
|
VO_Array.IterElement(StFunctor6::ShowElement, ZftMCP(VO_CHelpObj), VO_CHelpObj );
|
|||
|
|
|||
|
|
|||
|
IterEasy VH_Iter = VO_Array.ItHEasy();
|
|||
|
|
|||
|
__for1(int, i, VO_Array.size())
|
|||
|
{
|
|||
|
cout<<i<<"th value="<<
|
|||
|
VO_Array.ItD(VH_Iter)<<endl;
|
|||
|
|
|||
|
VO_Array.ItNext(VH_Iter);
|
|||
|
}
|
|||
|
///////////////////////////////
|
|||
|
|
|||
|
return 0;
|
|||
|
}/*
|
|||
|
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)*/
|
|||
|
|
|||
|
public:
|
|||
|
};/*
|
|||
|
template<typename TDummy=void*> class ZtCExamArray*/
|
|||
|
|
|||
|
}/*
|
|||
|
namespace ZNsExam*/
|
|||
|
|
|||
|
}/*
|
|||
|
namespace ZNsMain*/
|
|||
|
|
|||
|
|
|||
|
int main(int AR_ArgCnt, char* APP_ArgVal[])
|
|||
|
{
|
|||
|
return ZNsMain::ZNsExam::ZtCExamArray<>::Main();
|
|||
|
}/*
|
|||
|
int main(int AR_ArgCnt, char* APP_ArgVal[])*/
|
|||
|
|
|||
|
|
|||
|
/*////////////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
■ cigwin 컴파일
|
|||
|
|
|||
|
// g++ -mno-cygwin -o ZtCArray_000.exe ZtCArray_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300
|
|||
|
// g++ -mno-cygwin -o ZtCLoadXml_000_D.exe ZtCArray_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300 -D_DEBUG
|
|||
|
|
|||
|
■ mingw 컴파일
|
|||
|
|
|||
|
// /usr/local/mingw/bin/g++.exe -o ZtCArray_000.exe ZtCArray_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300
|
|||
|
// /usr/local/mingw/bin/g++.exe -o ZtCLoadXml_000_D.exe ZtCArray_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300 -D_DEBUG
|
|||
|
|
|||
|
■ Linux 컴파일
|
|||
|
|
|||
|
// g++ -o ZtCArray_000.exe ZtCArray_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/
|
|||
|
// g++ -o ZtCLoadXml_000_D.exe ZtCArray_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D_DEBUG
|
|||
|
|
|||
|
■ Ubuntu 컴파일
|
|||
|
|
|||
|
g++ -o ZtCArray_000.exe ZtCArray_000.cpp -I../
|
|||
|
g++ -o ZtCArray_000_D.exe ZtCArray_000.cpp -I../ -D_DEBUG
|
|||
|
|
|||
|
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ gcc --version
|
|||
|
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
|
|||
|
Copyright (C) 2019 Free Software Foundation, Inc.
|
|||
|
This is free software; see the source for copying conditions. There is NO
|
|||
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|||
|
|
|||
|
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ date
|
|||
|
Sun Aug 24 00:05:51 DST 2025
|
|||
|
|
|||
|
■ 실행
|
|||
|
|
|||
|
./ZtCArray_000.exe
|
|||
|
./ZtCArray_000_D.exe
|
|||
|
|
|||
|
////////////////////////////////////////////////////////////////////////////////////////*/
|