Difference between revisions of "Week 5"

From CDOT Wiki
Jump to: navigation, search
(Created page with 'Creating pointers to functions type foo(type 1, type2, type3, etc); type (*P)(type1, type2, type3, etc); P is a pointer variable to a function foo. Assigning a function to a …')
(No difference)

Revision as of 12:40, 9 June 2010

Creating pointers to functions

type foo(type 1, type2, type3, etc);

type (*P)(type1, type2, type3, etc);

P is a pointer variable to a function foo.

Assigning a function to a pointer variable:

P = foo;

In C (or C++), x = (*P)(type1, type2, type3);

In C++, x = P(y, z, x);

In C, everything upcasts. (so if you have an expression, it will upcast all the variables to the largest type).