问题描述
代码使用 Dev C++ 编译并运行得很好,但在 VS2017 下,我在 Get::Init()
处收到错误 C2276。我有点惊讶,因为这段代码是从第 126 行 Void TComrdcost::init()
处的代码 https://hevc.hhi.fraunhofer.de/HM-doc/_t_com_rd_cost_8cpp_source.html 中提取的,它在 VS2017 下编译得很好。我哪里错了?我错过了什么?
编辑:在 static int xGetSSE16N( distParam* pcDtParam )
解决问题之前设置 keyword 静态。有人可以解释为什么吗?问题仍然存在于 Dev C++ 中,它在没有 static 和 VS2017 的情况下解决了问题?
错误 C2276 '&': 对绑定成员函数表达式的非法操作"
#include <iostream>
using namespace std;
class distParam;
typedef int (*FpdistFunc) (distParam*); // int FpdistFunc(distParam*)
class distParam {
public:
FpdistFunc CustomFunction;
};
class Get {
public:
FpdistFunc m_afpdistortFunc[2];
int xGetSSE16N( distParam* pcDtParam ) {
std::cout << "xGetSSE16N is called \n\n";
return 1000;
}
void init() {
m_afpdistortFunc[0] = (FpdistFunc) (&xGetSSE16N);
}
void SetdistFunc(distParam *p) {
p->CustomFunction = m_afpdistortFunc[0];
}
};
int main() {
distParam m_cdistParam;
Get a;
a.init();
a.SetdistFunc(&m_cdistParam);
//execute the custom function
int uiSad = m_cdistParam.CustomFunction( &m_cdistParam );
std::cout << "uiSAD =" << uiSad;
return 0;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)