- genericthunk_source_sample_executable.zip
- GenericThunk_source_sample
- include
- sample
- Thunk
- CdeclToCdecl
- CdeclToCdecl.vcproj
- CdeclToCdecl.vcproj.OWNCOMPUTER.OwnWaterloo.user
- CdeclToStd
- CdeclToStd.vcproj
- CdeclToStd.vcproj.OWNCOMPUTER.OwnWaterloo.user
- release
- CdeclToCdecl.exe
- StdToCdecl.exe
- StdToStd.exe
- ThisToCdecl.exe
- ThisToStd.exe
- StdToCdecl
- StdToCdecl.vcproj
- StdToCdecl.vcproj.OWNCOMPUTER.OwnWaterloo.user
- StdToStd
- StdToStd.vcproj
- StdToStd.vcproj.OWNCOMPUTER.OwnWaterloo.user
- TestSrc
- ThisToCdecl
- ThisToCdecl.vcproj
- ThisToCdecl.vcproj.OWNCOMPUTER.OwnWaterloo.user
- ThisToStd
- ThisToStd.vcproj
- ThisToStd.vcproj.OWNCOMPUTER.OwnWaterloo.user
- Thunk.sln
- src
- genericthunk_source_sample.zip
- genericthunk_source.zip
- GenericThunk_source
- include
- src
|
#include <Thunk.h>
#include "TestClass.h"
using namespace std;
using Thunk::CThunk;
using Thunk::Helper;
//CThunk t; // CThunk is also a define in Preprocessor
// these Preprocessor macro allow us test Thunk with one set of source code
CThunk t1,t2,t3;
int main()
{
cout<<"C Style Functions "<<PLAIN_CONVENTION_NAME<<endl;
cout<<"C++ Method "<<METHOD_CONVENTION_NAME<<endl;
cout<<typeid(CThunk).name()<<" ,size = "<<sizeof(CThunk)<<endl<<endl;
C1 obj1(4,"obj1");
t1.Attach(&obj1);
t1.Attach(MF1);
int i = t1;
CB1 = t1;
{
double result = CB1(2,3);
cout<<"result = "<<result<<endl<<endl;
}
t1.Attach(MF2);
CB2 = t1.MakeCallback<CBFun2>();
{
int result = CB2(7,8,6);
cout<<"result = "<<result<<endl<<endl;
}
t1.AttachMethod(&C1::Fun3);
CB3 = t1.MakeCallback<CBFun3>();
CB3(326);
t1.Attach(MF4);
CB4 = t1.MakeCallback<CBFun4>();
{
CLarge result = CB4('i',1,2,2.2);
cout<<"result = "<<result<<endl<<endl;
}
t1.Attach(MF5);
CB5 = t1.MakeCallback<CBFun5>();
{
int result = CB5(15);
cout<<"result = "<<result<<endl<<endl;
}
cout<<endl<<"operator =, ";
t2 = t1;
if (t1==t2)
cout<<" operator == :both OK"<<endl;
else
cout<<" operator == :failed"<<endl;
CB5 = t2.MakeCallback<CBFun5>();
{
int result = CB5(12);
cout<<"result = "<<result<<endl<<endl;
}
system("pause");
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.