设为首页 加入收藏

TOP

Fibnacci序列(递归方法)
2013-02-08 14:34:00 】 浏览:726
Tags:Fibnacci 序列 方法

  很久以前已经说过,C++(www.cppentry.com)指向类成员函数的指针非常变态, 如果要把类成员函数作为线程 pthread_create 的参数, 就更复杂!

  class A{

  public:

  void run(){

  }

  static void *run_helper(void *arg){

  ((A *)arg)->run();

  return (void *)NULL;

  }

  };

  A a;

  pthread_t t;

  pthread_create(&t, NULL, &A::run_helper, &a);

  本来我们希望把 a.run 作为参数, 为此, 必须创建一个 static 的 run_helper() 函数, 然后在 run_helper() 中调用 run()。

  Related posts:

  TCP/IP 指数增长和线性增长的编程(www.cppentry.com)实现

  关于 C++(www.cppentry.com) 中的函数指针

  C#封装log4net

  使用ServletContextListener在服务器启动和关闭时创建和关闭缓存

  如何使用ServletContextListener

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇自动化ping 下一篇C/C++/Java/C#的基础类型

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目