fpointer.cc revision 1.3
1#include "stdio.h" 2 3int foo(){ 4 return 11; 5} 6 7int bar(){ 8 return 12; 9} 10 11int bar(int){ 12 printf ("bar(int)\n"); 13 return 13; 14} 15 16int bar(char){ 17 printf ("bar(char)\n"); 18 return 14; 19} 20 21int (*p1)() = &foo; 22int (*p2)() = &bar; 23int (*p[2])() = {p1,p2}; 24 25int (*p3)(int) = &bar; 26int (*p4)(char) = &bar; 27 28int main () 29{ 30 p1 (); 31 p2 (); 32 33 p[0](); 34 p[1](); 35 36 p3 ('a'); 37 p4 (1); 38 39 return 0; 40} 41