Wayne的博客

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  C/C++

摘要:最近在写一个功能的时候,涉及到回调函数的传递,最后用了传递函数指针的办法. A和B两个文件,A需要传一个函数int fun(char*,char*) 给B文件的Bclass类里面在B.h里面这样定义:typedef int(*Pfun)(char*,char*);class B{private: static Pfun callback;......public:...... static void valuePfun(Pfun fun) {callback = fun}; ......};在B.cpp里面:Pfun B::callback = NULL; //初始化在A里面,假如函数是 .. 阅读全文
posted @ 2012-04-27 10:26 Wayne Cheng 阅读(974) 评论(0) 推荐(0)

摘要:class base{ protected: int a; public: base() : a(1){} virtual void print () { cout << a << endl;}};class derived : public base{ private: int b; virtual void print () { base::print(); cout << b <<endl; } public: derived () : b(2) {}};derived d;base *b = &d; //OKderived* p 阅读全文
posted @ 2012-04-22 00:28 Wayne Cheng 阅读(393) 评论(0) 推荐(0)

摘要:得到cpu占有率的API函数:GetSystemTimes得到内存使用情况的API函数:GlobalMemoryStatusEx Function Retrieves information about the system's current usage of both physical and virtual memory.GetPerformanceInfo Function Retrieves the performance values contained in the PERFORMANCE_INFORMATION structure获取特定程序的内存使用情况用:GetPr 阅读全文
posted @ 2011-11-08 16:01 Wayne Cheng 阅读(5386) 评论(0) 推荐(0)