KiCad PCB EDA Suite
delegate_example.cpp
Go to the documentation of this file.
1 #include <cstdio>
2 #include <string>
3 
4 #include <tool/delegate.h>
5 
6 class MyClass
7 {
8 public:
9  int MyMethod( const string& arg )
10  {
11  return arg.length();
12  }
13 };
14 
15 typedef 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 }
main()
int MyMethod(const string &arg)
DELEGATE< int, const string & > MyDelegate