/** * Implementation of structure containing a function pointer * @author gtowell * Created: April 20. 2021 * **/ #include #include "sp1.h" #include /** * The function to be pointed to * "static" means that the function is not visible outside this file. This * is a really ugly re-use of the static keyword * * @param p a pointer to a qq object * **/ static void printer(qq * p) { printf("QQ: %d %d\n", p->a, p->b); } /** * Constructor * Pretty standard except for the fact that it put a function * pointer into the sruct * **/ qq* makeQQ(int a, int b) { qq *q = malloc(1 * sizeof(qq)); q->a = a; q->b = b; q->printer = printer; }