Lecture overview -- Keyboard shortcut: 'u'  Previous page: Structures: Examples -- Keyboard shortcut: 'p'  Next page: User defined types -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 1 - Page 18 : 29
Notes about C++
From C to C++
Function types

Functions in C can be used as data of function type

  • Only two possible operations on a function

    • Calling the function

    • Take the address of the function

  • Functions as types and data

    • Dealt with by means of function pointers

    • Use of the dereference operator and the address operator is often implicit

    • Functions are first class data in C, but they are not closures

    • The declaration syntax is obscure - difficult to read

y:/Kurt/Files/Advanced-programming-cpp/c/function-types/func-1.cC program with function pointer.


y:/Kurt/Files/Advanced-programming-cpp/c/function-types/func-2.cSame program - without explicit use of the address and dereferencing operators.


y:/Kurt/Files/Advanced-programming-cpp/c/function-types/func-3.cSame program - using a typedef to capture the function type.


Go to exerciseAn array of functions