Thread Callbacks und Closures?: Kann mal einer was dazu erzählen. (32 answers)
Opened by Ronnie at 2003-11-23 22:15

esskar
 2003-12-01 18:17
#72656 #72656
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
also, man kann dies zun...

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
typedef int(*mycb)(bool);

int counter(bool reset = false)
{
  static int c = 0;
  if(reset) c=0;
  return c++;  
}

mycb x = counter;

printf("%i\n", (x)(false));
printf("%i\n", (x)(false));
printf("%i\n", (x)(true));


dann gibt es noch

Code: (dl )
1
2
3
4
5
6
7
int a = 0;
{
  printf("a = %i\n", a);
  a++;
  int b = 0;
}
// printf("b = %i\n", b); //b out of scope


was fehlt dir noch?\n\n

<!--EDIT|esskar|1070295593-->

View full thread Callbacks und Closures?: Kann mal einer was dazu erzählen.