WvStreams
wvcallbackex.cc
1/*
2 * A WvCallback example.
3 *
4 */
5
6#include "wvcallback.h"
7#include <stdio.h>
8
9//Declare a new type of WvCallback called WvMath
10//This WvCallbak can point to functions that take 2 input parameters, both of type
11//integer, and returns an integer value.
12DeclareWvCallback(2, int, WvMath, int, int);
13
14int addition(int a, int b)
15{
16 return a+b;
17}
18
19
20int main()
21{
22 WvMath callback(NULL); //Declare a WvCallback of type WvMath
23 //callback = wvcallback(WvMath, *this, Math::addition);
24 callback = addition; // Now callback becomes a function pointer to the addition function
25
26 int answer = callback(5, 6); //Bind input parameter values to callback, same
27 //way as we bind values to the addition function.
28
29 printf("answer = %d\n", answer);
30
31
32}
33