pointer to function

  指针、函数、数字、结构体、指针函数、函数指针 初学不好区分,做点儿实验来有效区分一下,以下代码采用dev-C++平台测试

//pointer to fucntion 函数功能是 基地址加偏移量得到偏移地址

#include<stdio.h>

void test(int *n,int *base,int x){  *n=x+*base;     }

main(){

 int *a;  a=new int;  *a=1;

 int *b;  b=new int; *b=2;   

void (*f) (int *m,int *mm,int n );  //一定要定义个和调用函数各方面形式都一致的指针函数

   f = test;  

   (*f)(b,a,3 ); printf("%p ", *b);

 (*f)(b,a,4 ); printf("%p ", *b);

 (*f)(b,a,5 ); printf("%p ", *b);

*a=6;

 (*f)(b,a,3 ); printf("%p ", *b);

 }

原文地址:https://www.cnblogs.com/nyc1893/p/4075235.html