Files
RepoMain/ZCppMain/test.cpp

211 lines
5.4 KiB
C++
Raw Normal View History

2021-02-25 17:51:25 +09:00
2021-02-26 17:21:25 +09:00
2021-02-25 17:52:07 +09:00
#include <iostream>
2021-03-09 16:33:27 +09:00
#include "ZCppMain/ZtCArray.H"
#include "ZCppMain/ZtCObjList.H"
2021-02-25 17:27:36 +09:00
2021-02-25 17:51:25 +09:00
2021-02-26 17:33:59 +09:00
using namespace std ;
using namespace ZNsMain ;
2021-02-25 17:27:36 +09:00
2021-02-25 17:51:25 +09:00
2021-02-26 17:58:57 +09:00
namespace ZNsMain{namespace ZNsHide
2021-02-26 17:57:28 +09:00
{
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*/
}/*
2021-02-26 18:00:29 +09:00
namespace ZNsHide*/}/*namespace ZNsMain*/
2021-02-26 17:57:28 +09:00
2021-03-09 16:38:34 +09:00
template<typename T> class ZtCMy
2021-03-09 16:51:51 +09:00
{ public: enum{EMyNum=10}; typedef T TypeData; };
2021-03-09 16:33:27 +09:00
2021-03-09 16:38:34 +09:00
template<typename T> class ZtCMy< ZNsMain::ZtCObjList<T> >
2021-03-09 16:51:51 +09:00
{ public: enum{EMyNum=20}; typedef T TypeData; };
2021-03-09 16:33:27 +09:00
2021-02-26 17:57:28 +09:00
2021-02-26 17:33:59 +09:00
int main(int ArgiCnt, char** AppArgu)
{
2021-03-08 22:10:49 +09:00
cout<<endl<<"!!! C++'s Great Start -- 2021-03-08 11:10:00 !!!"<<endl<<endl;
2021-02-25 17:27:36 +09:00
2021-02-26 17:33:59 +09:00
typedef ZNsMain::ZtCObjList<int> CListByInt;
2021-03-04 17:55:37 +09:00
typedef ZNsMain::ZtCArray <int> CArrayInt ;
2021-02-26 17:33:59 +09:00
2021-03-09 16:33:27 +09:00
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;
2021-03-09 16:51:51 +09:00
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>
*/
2021-03-09 16:33:27 +09:00
2021-03-10 11:28:37 +09:00
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;
2021-03-10 16:17:47 +09:00
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;
2021-03-10 11:28:37 +09:00
cout<<"# HereInt1 ="<< typeid(myi1).name()<<endl;
cout<<"# HereInt2 int* ="<< typeid(myi2).name()<<endl;
cout<<"# HereInt3 int& ="<< typeid(myi3).name()<<endl;
2021-03-10 13:03:09 +09:00
#ifdef __WIN
2021-03-10 11:28:37 +09:00
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;
2021-03-10 13:03:09 +09:00
#endif
2021-03-10 11:28:37 +09:00
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
*/
2021-02-26 17:33:59 +09:00
CListByInt VO_IntList;
2021-03-04 17:55:37 +09:00
CArrayInt VO_IntArr ;
2021-02-26 17:33:59 +09:00
2021-03-04 16:22:15 +09:00
VO_IntList.AddTail(10);
VO_IntList.AddTail(40);
VO_IntList.AddTail(20);
VO_IntList.AddTail(80);
VO_IntList.AddTail(90);
2021-02-26 17:33:59 +09:00
2021-03-04 17:55:37 +09:00
VO_IntArr.AddTail(123);
VO_IntArr.AddTail(153);
VO_IntArr.AddTail(543);
VO_IntArr.AddTail(553);
VO_IntArr.AddTail(983);
2021-02-26 17:41:18 +09:00
2021-03-04 16:14:44 +09:00
typedef ZtStTuple<int, int> ZCTuple;
2021-03-04 16:10:09 +09:00
ZCTuple VO_CTuple; VO_CTuple._1 = 1;
_FFS_(ZCShowData1)
2021-02-26 17:41:18 +09:00
(ZTypInt AiInt)
{
2021-03-08 20:29:43 +09:00
cout<<"# Elem1 : "<< AiInt << endl;
2021-02-26 17:55:33 +09:00
}/*
(ZTypInt AiInt)*/
2021-03-04 16:10:09 +09:00
_FFC_(ZCShowData1)
2021-03-04 15:49:03 +09:00
2021-03-04 16:10:09 +09:00
_FFS_(ZCShowData2)
2021-03-04 16:19:02 +09:00
(ZTypInt AiInt, ZCTuple& AR_CTuple)
2021-03-04 16:10:09 +09:00
{
2021-03-08 20:29:43 +09:00
cout<<"# Elem2 : "<< AiInt << ", nth=" << AR_CTuple._1++ << endl;
2021-03-04 16:10:09 +09:00
}/*
2021-03-04 16:19:02 +09:00
(ZTypInt AiInt, ZCTuple& AR_CTuple)*/
2021-03-04 16:10:09 +09:00
_FFC_(ZCShowData2)
2021-03-04 15:49:03 +09:00
2021-03-04 16:19:02 +09:00
_FFS_(ZCShowData3)
2021-03-08 22:09:33 +09:00
(ZTypInt AiInt, ZCTuple* AP_CTuple)
2021-03-04 16:19:02 +09:00
{
2021-03-08 22:09:33 +09:00
cout<<"# Elem3 : "<< AiInt << ", nth=" << AP_CTuple->_1++ << endl;
2021-03-04 16:19:02 +09:00
}/*
2021-03-08 20:27:36 +09:00
(ZTypInt AiInt, ZCTuple* AR_CTuple)*/
2021-03-04 16:19:02 +09:00
_FFC_(ZCShowData3)
2021-03-08 20:37:34 +09:00
_FFS_(ZCShowData4)
2021-03-08 22:11:29 +09:00
(ZTypInt AiInt, ZCTuple* AP_CTuple)
2021-03-08 20:37:34 +09:00
{
2021-03-08 22:09:33 +09:00
cout<<"# Elem4 : "<< AiInt << ", nth=" << AP_CTuple->_1++ << endl;
2021-03-08 20:37:34 +09:00
}/*
2021-03-08 22:11:29 +09:00
(ZTypInt AiInt, ZCTuple* AP_CTuple)*/
2021-03-08 20:37:34 +09:00
_FFC_(ZCShowData4)
2021-02-26 17:55:33 +09:00
2021-03-04 16:10:09 +09:00
ZNsHide::ZCFunctor1 VO_CFunctor1;
2021-02-26 18:02:09 +09:00
/* ZCFunctor1 선언이 main() 바깥에 있어야 하는 문제를 해결할 수 없을까. */
2021-02-26 17:55:33 +09:00
2021-03-04 16:10:09 +09:00
VO_IntList.IterElement(ZCShowData1::Exec);
2021-03-08 20:37:34 +09:00
VO_IntList.IterElemRef(ZCShowData2::Exec, VO_CTuple ); VO_CTuple._1=1 ;
2021-03-04 16:20:05 +09:00
VO_IntList.IterElement(ZCShowData3::Exec, &VO_CTuple);
2021-03-04 16:10:09 +09:00
VO_IntList.IterElement(&VO_CFunctor1 );
2021-03-08 20:37:34 +09:00
VO_IntArr .IterElement(&VO_CFunctor1 ); VO_CTuple._1=1 ;
VO_IntArr .IterElement(ZCShowData4::Exec, &VO_CTuple);
2021-02-26 17:33:59 +09:00
2021-03-09 16:33:27 +09:00
cout<< "# Press Any Key to exit" << endl; cin.get();
2021-02-25 17:51:25 +09:00
return 0;
}/*
int main(int ArgiCnt, char** AppArgu)*/
2021-02-26 17:33:59 +09:00
/*/////////////////////////////////////
g++ -o test.exe test.cpp -I..
/////////////////////////////////////*/