Multithreading 错误C2064:term不计算为具有0个参数的函数thread.hpp(60) 我正在创建C++游戏服务器。服务器创建了许多对象monster,每个monster都应该有其特定功能的线程

Multithreading 错误C2064:term不计算为具有0个参数的函数thread.hpp(60) 我正在创建C++游戏服务器。服务器创建了许多对象monster,每个monster都应该有其特定功能的线程,multithreading,class,object,boost,Multithreading,Class,Object,Boost,我得到一个错误: error C2064: term does not evaluate to a function taking 0 arguments thread.hpp(60) : while compiling class template member function 'void boost::detail::thread_data<F>::run(void)' monster.h: #ifndef _H_MONSTER_ #define _H_MONST

我得到一个错误:

 error C2064: term does not evaluate to a function taking 0 arguments
 thread.hpp(60) : while compiling class template member function 'void  
  boost::detail::thread_data<F>::run(void)'
monster.h

#ifndef _H_MONSTER_
#define _H_MONSTER_

//Additional include dependancies
#include <iostream>
#include <string>
#include "boost/thread.hpp"
using namespace std;

class monster
{
    public:
    //Functions
    monster(string temp_mob_name);
    ~monster();
    //Custom defined functions
    void mob_engine();

    int x;
    int y;
};

//Include protection
#endif
\ifndef\u H\u怪物_
#定义“怪物”_
//其他包括依赖性
#包括
#包括
#包括“boost/thread.hpp”
使用名称空间std;
类怪物
{
公众:
//功能
怪物(字符串temp\u mob\u name);
~monster();
//自定义函数
无效移动引擎();
int x;
int-y;
};
//包括保护
#恩迪夫

mob_引擎是一个非静态成员函数,因此它有一个隐式this参数

试试这个:

boost::thread make_thread(boost::bind(&monster::mob_engine, this));
根据这个类似的问题,您甚至可以通过简单地编写以下内容来避免使用bind:

boost::thread make_thread(&monster::mob_engine, this);

另外,您可能需要声明一个boost::thread成员变量来保留对线程的引用。

mob\u引擎是一个非静态成员函数,因此它有一个隐式this参数

试试这个:

boost::thread make_thread(boost::bind(&monster::mob_engine, this));
根据这个类似的问题,您甚至可以通过简单地编写以下内容来避免使用bind:

boost::thread make_thread(&monster::mob_engine, this);
此外,您可能还需要声明一个boost::thread成员变量以保留对线程的引用