2013-08-02 14:50:29 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <tool/delegate.h>
|
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
class MyClass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int MyMethod( const string& arg )
|
|
|
|
{
|
|
|
|
return arg.length();
|
|
|
|
}
|
2013-08-02 14:50:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef DELEGATE<int, const string&> MyDelegate;
|
|
|
|
|
|
|
|
main()
|
|
|
|
{
|
2013-10-14 11:43:57 +00:00
|
|
|
MyClass t1;
|
|
|
|
MyClass t2;
|
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
MyDelegate ptr1( &t1, &MyClass::MyMethod );
|
|
|
|
MyDelegate ptr2( &t2, &MyClass::MyMethod );
|
2013-10-14 11:43:57 +00:00
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
int retval1, retval2;
|
2013-10-14 11:43:57 +00:00
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
retval1 = ptr1( "apples" );
|
|
|
|
retval2 = ptr2( "cherries" );
|
2013-10-14 11:43:57 +00:00
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
return 0;
|
2013-10-14 11:43:57 +00:00
|
|
|
}
|