gpt4 book ai didi

c++ - _beginthreadex 的参数类型错误

转载 作者:行者123 更新时间:2023-11-30 02:03:55 27 4
gpt4 key购买 nike

要定义我的头文件中的线程:

class HttpClient
{
public:
...
unsigned int __stdcall PerformLogin(void*);
...

};

然后在我的 cpp 文件中我有:

unsigned int __stdcall PerformLogin(void*){
...
}

并调用我使用的线程

hThread = (HANDLE)_beginthreadex( NULL, 0, &PerformLogin, NULL, 0, &threadID );

但是我在 &PerformLogin 上有一个错误说:

the args of type unsigned int (__stdcall HttpClient::)(void) is not compatible with the param unsigned int (__stdcall*)(void*).

我明白这个错误,但我真的不知道如何解决这个问题!

最佳答案

解决此问题的一种可能方法是使成员函数static,尽管这意味着PerformLogin() 没有this指针,并且无法访问 HttpClient 的非静态成员。

另一种方法是将 PerformLogin() 完全从 HttpClient 中移出,并使其成为一个免费函数。

关于c++ - _beginthreadex 的参数类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11289855/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com