c++_成员函数回调
2024-09-07 11:16:06
//--------------------------------------------------------------------------- #include <vcl.h>
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1; class CAppleDemo
{
public:
CAppleDemo();
~CAppleDemo(); void fun1(void); void fun2(int a, int b); int fun3(int a);
}; #include <iostream> CAppleDemo::CAppleDemo()
{
// std::cout << "CAppleDemo::CAppleDemo()" << std::endl;
} CAppleDemo::~CAppleDemo()
{
// std::cout << "CAppleDemo::~CAppleDemo()" << std::endl;
} void CAppleDemo::fun1(void)
{
ShowMessage( "CAppleDemo::fun1()" );
} void CAppleDemo::fun2(int a, int b)
{
ShowMessage( "CAppleDemo::fun2() a="+(String)a+",b="+(String)b );
} int CAppleDemo::fun3(int a)
{
ShowMessage( "CAppleDemo::fun2() a="+(String)a); return a; } template<typename dst_type, typename src_type>
dst_type pointer_cast(src_type src)
{
return *static_cast<dst_type*>(static_cast<void*>(&src));
} template<typename dst_type, typename src_type>
dst_type union_cast(src_type src)
{
union{
src_type s;
dst_type d;
}u;
u.s = src;
return u.d;
} typedef void (__fastcall *FunFun1)(void* pThis, int edx);
typedef void (__fastcall *FunFun2)(void* pThis, int edx, int a, int b);
typedef int (__fastcall *FunFun3)(void* pThis, int edx, int a); typedef void (__fastcall *FunFunMain)(void* pThis, TObject *Sender); //---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender)
{
// CAppleDemo cAppleDemo; // FunFun1 fun1 = pointer_cast<FunFun1>(&CAppleDemo::fun1);
// FunFun2 fun2 = pointer_cast<FunFun2>(&CAppleDemo::fun2);
// FunFun3 fun3 = union_cast<FunFun3>(&CAppleDemo::fun3); // fun1(NULL, NULL);
// fun2(NULL, NULL, 11, 22);
// fun3(NULL, NULL, 33); FunFunMain pM = union_cast<FunFunMain>(&TForm1::Button1Click);
pM(NULL,Sender);
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
ShowMessage("Button1Click");
}
//---------------------------------------------------------------------------
最新文章
- windows 共享文件夹 给 mac
- web app性能大讨论
- C2第十次解题报告
- 用Linux命令wget进行整站下载
- TCP相关知识
- [Client]动检参数讨论与ONVIF
- pure学习笔记
- iOS开发的一些奇巧淫技(转载)
- echo 0000
- 使用Java实现二叉树的添加,删除,获取以及遍历
- net core体系-web应用程序-4asp.net core2.0 项目实战(1)-5项目数据库操作封装操作-EF框架
- php中__call() 和 __callStatic方法的使用
- pycharm 配置服务器,脚本,测试文件
- HttpClient和HttpGet 参数的优先级
- SSM框架搭建问题
- 快速沃尔什变换 FWT 学习笔记【多项式】
- 20155316 2016-2017-2 《Java程序设计》第2周学习总结
- Linux内核分析7
- SharedPreferences小技巧
- HLJU 1042 Fight (种类并查集)
热门文章
- (java 实现开箱即用基于 redis 的分布式锁
- [常用工具] 深度学习Caffe处理工具
- Java开发学习(五十)----MyBatisPlus快速开发之代码生成器解析
- 焦距的物理尺度、像素尺度之间的转换关系以及35mm等效焦距
- [Leetcode]移除链表元素
- AtCoder Beginner Contest 282 G - Similar Permutation
- 读Java8函数式编程笔记06_Lambda表达式编写并发程序
- activemq插件在eos中的开发
- 将Grafana嵌入自己的应用
- C#DataTableRow列值互转