// Copyright 2010, Someone
// Complex pointer to function declaration.
#ifndef _2C_EXCERCISE_1_H_
#define _2C_EXCERCISE_1_H_
// 18.2
// How can we declare an array of N elements, each a pointer to a function
// that returns a pointer to an int and takes two arguments: a double and
// a pointer to a function taking a double and returning a double?
#define N 10
int* (*Func_Ch18_2[N])(double a, double (* b_func)(double c));
// 18.3
// How can we declare a pointer to a function that takes a pointer to an
// array of 10 ints and an int and returns a pointer to an array of 10
// ints?
int (*Func_Ch18_3(int (*a_func)[10], int c))[10];
// Here's another answer.
typedef int(*ROWPTR)[10];
ROWPTR (*Func_Ch18_3_ANSWER_2)(ROWPTR, int);
// 18.4
// How would we declare a two-dimensional array of 10 rows of 20 elements,
// each of which is a pointer to a function that takes a pointer to void
// and returns no value?
void (*Func_Ch18_4[10][20])(void* a);
// 18.5
// How would we declare a pointer to a function that returns a pointer
// to a function that takes a pointer to void and an int and returns a
// pointer to void? The function takes a table of pointers to these
// functions and an int. What might we use this type for?
void* (*(*Func_Ch18_5)(void* (* a_func[])(void *, int), int b))(void *, int);
// Here's another answer.
typedef void* (*ROWPTR2)(void *,int);
ROWPTR2 (*Func_Ch18_5)(ROWPTR2 a_func[], int b);
#endif // _2C_EXCERCISE_1_H_
- Jun 24 Thu 2010 02:02
太可怕了!
close
全站熱搜
留言列表
禁止留言