(请注意,以下是基于实际代码的示例)
Foo.hpp:
#include <thread.h>
#include <iostream>
#include <string>
class Foo
{
private:
std::thread t;
std::string s;
int x;
int y;
public:
Foo();
Foo(std::string s, int x, int y);
void init();
void init(std::string s, int x, int y);
};
Foo.cpp中:
#include "Foo.cpp"
Foo::Foo()
{
this->thread = std::thread(static_cast<void (Foo::*)()>(&Foo::init), this);
}
Foo::Foo(std::string s, int x, int y)
{
this->thread = std::thread(static_cast<void (Foo::*)()>(&Foo::init), this, s, x, y);
}
// Foo::init() and Foo::init(std::string s, int x, int y) definitions
这导致g ++输出相当多的错误,其中最值得注意的可能是
no match for call to '(std::_Bind<std::_Mem_fn<void (Foo::*, std::basic_string<char>, int, int)>) ()' (*upCall)();
^
那我在这里做错了什么?