Week 5

From CDOT Wiki
Revision as of 11:40, 9 June 2010 by Jaburton1 (talk | contribs) (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 …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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).