Addendum to Friday's lecture.

In the class, Prof. Yee talked about pointers to functions while explaining the sample program. For those who have difficulty in understanding C, C pointers and pointers to function, here are some links. Also see the rule of thumb to resolve pointers successfully.

Pointers

Pointers to functions

A rule of thumb.

The answer to resolving the pointers successfully lies in knowing the order of precedence.

e.g.

Given, int (*fn) ( float )

Firstly we associate the parentheses with the appropriate keywords enclosed within them viz., *fn with the first pair and float with the second pair of parentheses respectively. We then resolve the first pair of parenthesis to result in a identifier by associating the asterisk with fn ( the order of precedence for '*' when used as a pointer is read from right to left ), which says that fn is a pointer. Then we associate the identifier so formed to the second pair of parentheses thereby creating a pointer to a function. Finally, we are able to decipher that fn is a pointer to a function that takes a float argument and returns an integer.