作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 TaskScheduler COM,这是我的代码:
typedef HRESULT(*FuncOfBoll)(_Out_ VARIANT_BOOL* b);
static bool GetBool(FuncOfBoll func)
{
VARIANT_BOOL b = VARIANT_FALSE;
HRESULT hr = func(&b);
if (FAILED(hr)) return FALSE;
return b == VARIANT_TRUE;
}
void test(ITaskSettings* settings)
{
bool b = GetBool(settings->get_StopIfGoingOnBatteries); // <= The error here
// ...
}
我收到以下错误:
Error C3867 'ITaskSettings::get_StopIfGoingOnBatteries': non-standard syntax; use '&' to create a pointer to member
我的错误是什么以及如何改正?
最佳答案
我猜测 get_StopIfGoingOnBatteries
是 ITaskSettings
的成员函数。当期望的参数类型是 FuncOfBoll
时,不能使用这样的函数。您需要创建一个包装函数并使用它。
ITaskSettings* currentSetttings = NULL;
HRESULT GetBoolWrapper(_Out_ VARIANT_BOOL* b)
{
return currentSetttings->get_StopIfGoingOnBatteries(b);
}
void test(ITaskSettings* settings)
{
currentSetttings = settings;
bool b = GetBool(GetBoolWrapper);
}
关于C++ Visual Studio 2015 “non-standard syntax; use ' &' to create a pointer to member”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39622640/
我是一名优秀的程序员,十分优秀!