KiCad PCB EDA Suite
Loading...
Searching...
No Matches
delegate_example.cpp
Go to the documentation of this file.
1#include <cstdio>
2#include <string>
3
4#include <tool/delegate.h>
5
6class MyClass
7{
8public:
9 int MyMethod( const string& arg )
10 {
11 return arg.length();
12 }
13};
14
15typedef DELEGATE<int, const string&> MyDelegate;
16
18{
19 MyClass t1;
20 MyClass t2;
21
22 MyDelegate ptr1( &t1, &MyClass::MyMethod );
23 MyDelegate ptr2( &t2, &MyClass::MyMethod );
24
25 int retval1, retval2;
26
27 retval1 = ptr1( "apples" );
28 retval2 = ptr2( "cherries" );
29
30 return 0;
31}
int MyMethod(const string &arg)
main()
DELEGATE< int, const string & > MyDelegate