Files
RepoMain/ZCppMainTest/ZtCArray_000.cpp

263 lines
9.0 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;
#if defined(__linux__) && defined(__GNUC__)
cout<<"# __GNUC__ : "<<__GNUC__<<endl;
#endif
#if defined(__cplusplus)
cout<<"# __cplusplus : "<<__cplusplus<<endl;
#endif
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 AI_ArgCnt, char* APP_ArgVal[])
{
return ZNsMain::ZNsExam::
ZtCExamArray<>::Main(AI_ArgCnt, APP_ArgVal);
}/*
int main(int AI_ArgCnt, char* APP_ArgVal[])*/
/*////////////////////////////////////////////////////////////////////////////////////////
■ cygwin 컴파일
// 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 ZtCArray_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 컴파일
g++.exe -o ZtCArray_000_mw.exe ZtCArray_000.cpp -I../
g++.exe -o ZtCArray_000_mw_D.exe ZtCArray_000.cpp -I../ -D_DEBUG
./ZtCArray_000_mw.exe
./ZtCArray_000_mw_D.exe
Administrator@q381-2673 UCRT64 /e/my_CPP/ZCpp/ZCppMainTest
# date
Sun Aug 24 10:47:09 KST 2025
Administrator@q381-2673 UCRT64 /e/my_CPP/ZCpp/ZCppMainTest
# g++ --version
g++.exe (Rev2, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 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.
■ Linux 컴파일
g++ -std=c++98 -o ZtCArray_000.exe ZtCArray_000.cpp -I../ -Wall -Wno-unused-function -Wno-misleading-indentation
g++ -std=c++98 -o ZtCArray_000_D.exe ZtCArray_000.cpp -I../ -Wall -Wno-unused-function -Wno-misleading-indentation -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
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[sauron@q381-2657 ZCppMainTest]$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[sauron@q381-2657 ZCppMainTest]$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 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.
■ 실행
./ZtCArray_000.exe
./ZtCArray_000_D.exe
////////////////////////////////////////////////////////////////////////////////////////*/