我有class A
一个函数void runThread()
来调用新线程。这是我A.cpp
的 withstruct SendInfo
和函数void thread(...)
不包含在头文件中A.h
:
//A.cpp
struct SendInfo{
int a;
std::string mess;
SendInfo(int _a, std::string _mess){
a = _a;
mess = _mess;
}
};
void thread(SendInfo* args){
std::cout << args->mess << std::endl; // Result here is nothing :-?
}
void A::runThread(){
SendInfo info(10,"dump_string");
std::cout << info.mess << std::endl; // Result here is "dump_string"
_beginthread((void(*)(void*))thread, 0, &info);
}
在 main 函数中,我调用runThread()
ofA object
时,结果info.mess
很好,但args->mess
没有字符串。那我的问题是什么?以及如何解决?