随笔分类 -  C/C++

C/C++中的函数指针-回调函数
摘要:常规函数指针 void(*fp)();典型的函数指针,用于指向无参数,无返回值的函数 void(*fp2)(int);使用typedef来定义函数指针的类型 typedef void(* FP)(); FP fp3; // 和上面的fp一样的定义。代码示例:#include "stdafx.h"#define USING_LEAK_CHECK 1 #ifndef _crtdbg_map_alloc #define _crtdbg_map_alloc #endif #include #if USING_LEAK_CHECK #include #endif #include.. 阅读全文

posted @ 2012-03-08 11:44 junetan 阅读(33) 评论(0) 推荐(0)

Visual C++内置内存泄露检测
摘要:#define USING_LEAK_CHECK 1 #ifndef _crtdbg_map_alloc #define _crtdbg_map_alloc #endif #include #if USING_LEAK_CHECK #include #endif char * my1(int num){ char *p=(char *)malloc(sizeof(char)*num); return p;}void my2(){ char * s=NULL; s=my1(100); strcpy(s,"hello world"); //free(s);}int _tmain 阅读全文

posted @ 2012-03-06 11:51 junetan 阅读(31) 评论(0) 推荐(0)

导航