KiCad PCB EDA Suite
delegate_example.cpp File Reference
#include <cstdio>
#include <string>
#include <tool/delegate.h>

Go to the source code of this file.

Classes

class  MyClass
 

Typedefs

typedef DELEGATE< int, const string & > MyDelegate
 

Functions

 main ()
 

Typedef Documentation

typedef DELEGATE<int, const string&> MyDelegate

Definition at line 17 of file delegate_example.cpp.

Function Documentation

main ( )

Definition at line 19 of file delegate_example.cpp.

References MyClass::MyMethod().

20 {
21  MyClass t1;
22  MyClass t2;
23 
24  MyDelegate ptr1( &t1, &MyClass::MyMethod );
25  MyDelegate ptr2( &t2, &MyClass::MyMethod );
26 
27  int retval1, retval2;
28 
29  retval1 = ptr1( "apples" );
30  retval2 = ptr2( "cherries" );
31 
32  printf( "Object 1 returned %d, object 2 returned %d\n", retval1, retval2 );
33  return 0;
34 }
int MyMethod(const string &arg)
DELEGATE< int, const string & > MyDelegate