在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1.需要头文件#include <functional> 2.定义functor变量 : std::tr1::function< T* (P1*, P2*) > DpdCreateT; BCB可以先typedef一下函数声明 typedef T* (Delegate)(P1*, P2*); std::tr1::function< Delegate > DpdCreateT;
3.连接: 类函数 xx.DpdCreateT = std::tr1::bind( & ZZZ::CreateConnection, //类函数地址 & instance, // 对象实例地址 std::tr1::placeholders::_1, // 参数1占位符 std::tr1::placeholders::_2 // 参数1占位符 ); 全局函数,直接赋值即可 xx.DpdCreateT = GlobalCreateFunction;
//------------------------------------------------------------------------------ 简单函数指针 typedef void (*FooPtr)(int, double); void Foo(int anInt, double aDouble) FooPtr func = &Foo; //------------------------------------------------------------------------------ 成员函数指针 typedef int (SomeClass::*MemberFooPtr)(int, double);
SomeClass sc; p = &SomeClass::Foo;
//------------------------------------------------------------------------------- VS 2008中 #include <functional> 定义: typedef void (SetFrameValueActionDelegate)(T*, V frameValue);
绑定: mWeekViewGroupLocationAnimation.SetFrameValueAction
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论