93 lines
1.6 KiB
C++
93 lines
1.6 KiB
C++
|
|
|
|
#include <iostream>
|
|
#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;
|
|
|
|
CListByInt VO_IntList;
|
|
|
|
VO_IntList.AddTail(1);
|
|
VO_IntList.AddTail(4);
|
|
VO_IntList.AddTail(2);
|
|
VO_IntList.AddTail(8);
|
|
VO_IntList.AddTail(9);
|
|
|
|
|
|
_FFS_(ZCShowData)
|
|
(ZTypInt AiInt)
|
|
{
|
|
cout<<"# Elem : "<< AiInt << endl;
|
|
}/*
|
|
(ZTypInt AiInt)*/
|
|
_FFC_(ZCShowData)
|
|
|
|
|
|
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*/
|
|
|
|
|
|
//ZNsHide::ZCFunctor1 VO_CFunctor1;
|
|
ZCFunctor1 VO_CFunctor1;
|
|
/* ZCFunctor1 선언이 main() 바깥에 있어야 하는 문제를 해결할 수 없을까. */
|
|
|
|
VO_IntList.IterElement(ZCShowData::Exec);
|
|
VO_IntList.IterElement(&VO_CFunctor1 );
|
|
|
|
return 0;
|
|
}/*
|
|
int main(int ArgiCnt, char** AppArgu)*/
|
|
|
|
|
|
/*/////////////////////////////////////
|
|
|
|
|
|
■ 컴파일
|
|
|
|
g++ -o test.exe test.cpp -I..
|
|
|
|
|
|
/////////////////////////////////////*/ |