242 lines
6.3 KiB
C++
242 lines
6.3 KiB
C++
|
|
|
|
#include <iostream>
|
|
#include "ZCppMain/ZtCArray.H"
|
|
#include "ZCppMain/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*/
|
|
|
|
|
|
template<typename T> class ZtCMy
|
|
{ public: enum{EMyNum=10}; typedef T TypeData; };
|
|
|
|
template<typename T> class ZtCMy< ZNsMain::ZtCObjList<T> >
|
|
{ public: enum{EMyNum=20}; typedef T TypeData; };
|
|
|
|
|
|
int main(int ArgiCnt, char** AppArgu)
|
|
{
|
|
cout<<endl<<"!!! C++'s Great Start -- 2021-03-08 11:10:00 !!!"<<endl<<endl;
|
|
|
|
|
|
typedef ZNsMain::ZtCObjList<int> CListByInt;
|
|
typedef ZNsMain::ZtCArray <int> CArrayInt ;
|
|
|
|
typedef ZtCMy<int> CMy1;
|
|
typedef ZtCMy<CListByInt> CMy2;
|
|
typedef ZtCMy<CArrayInt > CMy3;
|
|
|
|
cout<<"# CMy1::EMyNum="<<CMy1::EMyNum<<endl;
|
|
cout<<"# CMy2::EMyNum="<<CMy2::EMyNum<<endl;
|
|
cout<<"# CMy3::EMyNum="<<CMy3::EMyNum<<endl;
|
|
|
|
cout<<"# CMy1::TypeData="<<typeid(CMy1::TypeData).name()<<endl;
|
|
cout<<"# CMy2::TypeData="<<typeid(CMy2::TypeData).name()<<endl;
|
|
cout<<"# CMy3::TypeData="<<typeid(CMy3::TypeData).name()<<endl;
|
|
/*
|
|
# CMy1::EMyNum=10
|
|
# CMy2::EMyNum=20
|
|
# CMy3::EMyNum=10
|
|
# CMy1::TypeData=int
|
|
# CMy2::TypeData=int
|
|
# CMy3::TypeData=class ZNsMain::ZtCArray<int,int const &,long>
|
|
*/
|
|
|
|
cout<<"# int ="<<typeid(int).name()<<endl;
|
|
cout<<"# int*="<<typeid(int*).name()<<endl;
|
|
cout<<"# int&="<<typeid(int&).name()<<endl;
|
|
|
|
int i1= 10;
|
|
int* i2=&i1;
|
|
int& i3= i1;
|
|
|
|
cout<<"# int ="<<typeid(i1).name()<<endl;
|
|
cout<<"# int*="<<typeid(i2).name()<<endl;
|
|
cout<<"# int&="<<typeid(i3).name()<<endl;
|
|
|
|
typedef int HereInt1;
|
|
typedef int* HereInt2;
|
|
typedef int& HereInt3;
|
|
|
|
HereInt1 myi1= 100 ;
|
|
HereInt2 myi2= &myi1;
|
|
HereInt3 myi3= myi1 ; myi3=123;
|
|
|
|
ZtCRef<int> myref(myi1);
|
|
ZtCCheckRef< int > myrefcheck1(myi1); myrefcheck1.GetData();
|
|
ZtCCheckRef< ZtCRef<int> > myrefcheck2(myi1); myrefcheck2.GetData();
|
|
|
|
myi1=4321;
|
|
|
|
cout<<"# myrefcheck1.GetData()="<<myrefcheck1.GetData()<<endl;
|
|
cout<<"# myrefcheck2.GetData()="<<myrefcheck2.GetData()<<endl;
|
|
|
|
cout<<"# HereInt1 ="<< typeid(myi1).name()<<endl;
|
|
cout<<"# HereInt2 int* ="<< typeid(myi2).name()<<endl;
|
|
cout<<"# HereInt3 int& ="<< typeid(myi3).name()<<endl;
|
|
|
|
#ifdef __WIN
|
|
cout<<"# HereInt1 hash="<< typeid(myi1).hash_code()<<endl;
|
|
cout<<"# HereInt2 hash="<< typeid(myi2).hash_code()<<endl;
|
|
cout<<"# HereInt3 hash="<< typeid(myi3).hash_code()<<endl;
|
|
|
|
cout<<"# HereInt1 raw ="<< typeid(myi1).raw_name()<<endl;
|
|
cout<<"# HereInt2 raw ="<< typeid(myi2).raw_name()<<endl;
|
|
cout<<"# HereInt3 raw ="<< typeid(myi3).raw_name()<<endl;
|
|
#endif
|
|
|
|
cout<<"# HereInt1 ="<< myi1<<endl;
|
|
cout<<"# HereInt2 int* ="<<*myi2<<endl;
|
|
cout<<"# HereInt3 int& ="<< myi3<<endl;
|
|
/*
|
|
# HereInt1 =int
|
|
# HereInt2 int* =int *
|
|
# HereInt3 int& =int
|
|
|
|
# HereInt1 hash=3440116983
|
|
# HereInt2 hash=2450196518
|
|
# HereInt3 hash=3440116983
|
|
|
|
# HereInt1 raw =.H
|
|
# HereInt2 raw =.PAH
|
|
# HereInt3 raw =.H
|
|
|
|
# HereInt1 =123
|
|
# HereInt2 int* =123
|
|
# HereInt3 int& =123
|
|
*/
|
|
|
|
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 ZNsMain::ZtStTuple<int, ZNsMain::ZtCRef<int> > ZStTuple2;
|
|
|
|
int i=1;
|
|
int& j=i;
|
|
|
|
ZStTuple2 VO_ZStTuple2 = ZNsMain::ZftMakeArguTuple<int, ZNsMain::ZtCRef<int> >
|
|
(i, ZNsMain::ZtCRef<int>(j).GetData() );
|
|
|
|
VO_ZStTuple2._2 = 3;
|
|
|
|
|
|
|
|
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* AP_CTuple)
|
|
{
|
|
cout<<"# Elem4 : "<< AiInt << ", nth=" << AP_CTuple->_1++ << endl;
|
|
}/*
|
|
(ZTypInt AiInt, ZCTuple* AP_CTuple)*/
|
|
_FFC_(ZCShowData4)
|
|
|
|
_FFS_(ZCShowData5)
|
|
(ZTypInt AiInt, int& AiIndex)
|
|
{
|
|
cout<<"# Elem5 : "<< AiInt << ", nth=" << AiIndex++ << endl;
|
|
}/*
|
|
(ZTypInt AiInt, int& AiIndex)*/
|
|
_FFC_(ZCShowData5)
|
|
|
|
_FFS_(ZCShowData6)
|
|
(ZTypInt AiInt, int& AiIndex)
|
|
{
|
|
cout<<"# Elem6 : "<< AiInt << ", nth=" << AiIndex++ << endl;
|
|
}/*
|
|
(ZTypInt AiInt, int& AiIndex)*/
|
|
_FFC_(ZCShowData6)
|
|
|
|
|
|
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); VO_CTuple._1=1 ;
|
|
VO_IntArr .IterElement(ZCShowData5::Exec, ZNsMain::ZtCRef<int>(VO_CTuple._1));
|
|
VO_IntList.IterElement(ZCShowData5::Exec, ZNsMain::ZtCRef<int>(VO_CTuple._1));
|
|
|
|
cout<< "# Press Any Key to exit" << endl; cin.get();
|
|
|
|
return 0;
|
|
}/*
|
|
int main(int ArgiCnt, char** AppArgu)*/
|
|
|
|
|
|
/*/////////////////////////////////////
|
|
|
|
|
|
■ 컴파일
|
|
|
|
g++ -o test.exe test.cpp -I..
|
|
|
|
|
|
/////////////////////////////////////*/ |