Пример #1
0
int main(){
	void (*fun_ptr)(void) = &do_something_else;
	fun_ptr();
	int (*cal_ptr)(int, int, int) = &average;
	int avg = cal_ptr(2,4,4);
	printf("%d",avg);
	return 0;
}
Пример #2
0
//-----------------------------------------------
// 				tb_time_ticker()
// This function recives..
//		-A pointer to the universe
//		-Number of time ticks to progress
//		-A pointer to a function--\
//		       /------------------/
//		       |
//	The function recived will be used
//	on every point in space
//		function (Universe pointer, x, y)
//-----------------------------------------------
void tb_time_ticker( struct toobit_space* in_u, unsigned int tc, void (*fun_ptr)(struct toobit_space*, unsigned int, unsigned int )){
  int x,y;
  tc=TB_OBSERVATION_TIME_GAP;
  while(tc--){			// progress through 1 observation frame of time ticks
    y=TB_SPACE_SIZE_Y;		// cycle each point in space
    while(y--){
      x=TB_SPACE_SIZE_X;
      while(x--){
      fun_ptr(in_u,x,y);	//run the function we got on each particle
      }
    }
    // copy .space_next into .space ( now=next )
    memcpy((*in_u).space,(*in_u).space_next,TB_SPACE_DATA_SIZE_BYTES);
    }
  return;
  }
 DataFrame* DataFrameCreator::CreateInstance(const string& class_name) {
   CreateFunPtr fun_ptr = ptrfun_map[class_name];
   return fun_ptr();
 }