119 lines
2.6 KiB
C++
119 lines
2.6 KiB
C++
|
|
|
|
#include <iostream>
|
|
#include "ZtCArray.H"
|
|
#include "ZtCObjList.H"
|
|
|
|
|
|
using namespace std ;
|
|
using namespace ZNsMain ;
|
|
|
|
|
|
namespace ZNsMain{namespace ZNsHide
|
|
{
|
|
|
|
class ZCFunctor1
|
|
{
|
|
private:
|
|
ZTypInt mi_Index;
|
|
public :
|
|
|
|
ZCFunctor1(){mi_Index=0;}
|
|
|
|
void operator()(int ArgiValue)
|
|
{ cout<<"# index="<<++mi_Index<<", Value="<<ArgiValue<<endl; }
|
|
public :
|
|
};/*
|
|
class ZCFunctor1*/
|
|
|
|
}/*
|
|
namespace ZNsHide*/}/*namespace ZNsMain*/
|
|
|
|
|
|
|
|
int main(int ArgiCnt, char** AppArgu)
|
|
{
|
|
cout<<endl<<"!!! C++'s Great Start !!!"<<endl<<endl;
|
|
|
|
|
|
typedef ZNsMain::ZtCObjList<int> CListByInt;
|
|
typedef ZNsMain::ZtCArray <int> CArrayInt ;
|
|
|
|
CListByInt VO_IntList;
|
|
CArrayInt VO_IntArr ;
|
|
|
|
VO_IntList.AddTail(10);
|
|
VO_IntList.AddTail(40);
|
|
VO_IntList.AddTail(20);
|
|
VO_IntList.AddTail(80);
|
|
VO_IntList.AddTail(90);
|
|
|
|
VO_IntArr.AddTail(123);
|
|
VO_IntArr.AddTail(153);
|
|
VO_IntArr.AddTail(543);
|
|
VO_IntArr.AddTail(553);
|
|
VO_IntArr.AddTail(983);
|
|
|
|
|
|
typedef ZtStTuple<int, int> ZCTuple;
|
|
|
|
ZCTuple VO_CTuple; VO_CTuple._1 = 1;
|
|
|
|
|
|
_FFS_(ZCShowData1)
|
|
(ZTypInt AiInt)
|
|
{
|
|
cout<<"# Elem1 : "<< AiInt << endl;
|
|
}/*
|
|
(ZTypInt AiInt)*/
|
|
_FFC_(ZCShowData1)
|
|
|
|
_FFS_(ZCShowData2)
|
|
(ZTypInt AiInt, ZCTuple& AR_CTuple)
|
|
{
|
|
cout<<"# Elem2 : "<< AiInt << ", nth=" << AR_CTuple._1++ << endl;
|
|
}/*
|
|
(ZTypInt AiInt, ZCTuple& AR_CTuple)*/
|
|
_FFC_(ZCShowData2)
|
|
|
|
_FFS_(ZCShowData3)
|
|
(ZTypInt AiInt, ZCTuple* AP_CTuple)
|
|
{
|
|
cout<<"# Elem3 : "<< AiInt << ", nth=" << AP_CTuple->_1++ << endl;
|
|
}/*
|
|
(ZTypInt AiInt, ZCTuple* AR_CTuple)*/
|
|
_FFC_(ZCShowData3)
|
|
|
|
_FFS_(ZCShowData4)
|
|
(ZTypInt AiInt, ZCTuple* AR_CTuple)
|
|
{
|
|
cout<<"# Elem4 : "<< AiInt << ", nth=" << AP_CTuple->_1++ << endl;
|
|
}/*
|
|
(ZTypInt AiInt, ZCTuple* AR_CTuple)*/
|
|
_FFC_(ZCShowData4)
|
|
|
|
|
|
ZNsHide::ZCFunctor1 VO_CFunctor1;
|
|
/* ZCFunctor1 선언이 main() 바깥에 있어야 하는 문제를 해결할 수 없을까. */
|
|
|
|
VO_IntList.IterElement(ZCShowData1::Exec);
|
|
VO_IntList.IterElemRef(ZCShowData2::Exec, VO_CTuple ); VO_CTuple._1=1 ;
|
|
VO_IntList.IterElement(ZCShowData3::Exec, &VO_CTuple);
|
|
VO_IntList.IterElement(&VO_CFunctor1 );
|
|
VO_IntArr .IterElement(&VO_CFunctor1 ); VO_CTuple._1=1 ;
|
|
VO_IntArr .IterElement(ZCShowData4::Exec, &VO_CTuple);
|
|
|
|
return 0;
|
|
}/*
|
|
int main(int ArgiCnt, char** AppArgu)*/
|
|
|
|
|
|
/*/////////////////////////////////////
|
|
|
|
|
|
■ 컴파일
|
|
|
|
g++ -o test.exe test.cpp -I..
|
|
|
|
|
|
/////////////////////////////////////*/ |