gpt4 book ai didi

c++ - 错误 C2440 和仿函数

转载 作者:行者123 更新时间:2023-11-28 07:20:42 25 4
gpt4 key购买 nike

也许你会知道,我得到一个错误:

 error C2440: 'initializing' : cannot convert from 'int' 
Conversion from integral type to pointer type requires reinterpret_cast

它转到 ' MS VS 2010 文件夹中的文件:

template<class _Other1,
class _Other2>
_Pair_base(_Other1&& _Val1, _Other2&& _Val2)
: first(_STD forward<_Other1>(_Val1)),
second(_STD forward<_Other2>(_Val2))
{ // construct from moved values
}

我一直在寻找不同的解决方案,但找不到正确的解决方案。

最佳答案

错误说

'initializing' : cannot convert from 'int' to 'EnterFunctor *'

您共享的代码的唯一部分是

functors.push_back(make_pair(sessionStartFunc, 
pair<EnterFunctor*, ExitFunctor*>(NULL,sessionStartExit)));

如果 NULL 被#defined 为 0 这给你一个 int 但你 promise 了一个 pair 指针,所以下一行该错误表明您可以使用强制转换使 NULL 成为正确的指针类型。

关于c++ - 错误 C2440 和仿函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19512623/

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