明显调用的表达式前的括号必须具有(指针)函数类型 编译器错误 C2064
看到“明显调用的表达式前的括号必须具有(指针)函数类型”这句时我才发现我的语文水平有多烂,怎么看都看不懂,折腾了半天才知道是哪里出了问题。
举个简单的例子
class CTest
{
void (CTest::*m_pFun)(); void CallFun()
{
(this->*m_pFun)(); //OK,对象指针和函数名一定要用括号括起来,函数名前面要加上*号
this->*m_pFun(); //error
(this->m_pFun)(); //error
}
//本文链接http://www.cnblogs.com/vcpp123/p/5902839.html
};
详细说明请参阅MSDN,链接:https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=ZH-CN&k=k(C2064)&rd=true
编译器错误 C2064
term does not evaluate to a function taking N arguments
A call is made to a function through an expression.The expression does not evaluate to a pointer to a function that takes the specified number of arguments.
In this example, the code attempts to call non-functions as functions.The following sample generates C2064:
// C2064.cpp
int i, j;
char* p;
void func() {
j = i(); // C2064, i is not a function
p(); // C2064, p doesn't point to a function
}
You must call pointers to non-static member functions from the context of an object instance.The following sample generates C2064, and shows how to fix it:
// C2064b.cpp
struct C {
void func1() {}
void func2() {}
}; typedef void (C::*pFunc)(); int main() {
C c;
pFunc funcArray[2] = { &C::func1, &C::func2 };
(funcArray[0])(); // C2064
(c.*funcArray[0])(); // OK - function called in instance context
}
Within a class, member function pointers must also indicate the calling object context.The following sample generates C2064 and shows how to fix it:
// C2064d.cpp
// Compile by using: cl /c /W4 C2064d.cpp
struct C {
typedef void (C::*pFunc)();
pFunc funcArray[2];
void func1() {}
void func2() {}
C() {
funcArray[0] = &C::func1;
funcArray[1] = &C::func2;
}
void func3() {
(funcArray[0])(); // C2064
(this->*funcArray[0])(); // OK - called in this instance context
}
};
最新文章
- H3C汇聚层交换机认证在线人数展示系统之需求说明和功能点说明
- LVS_DR模式构建配置
- 用 C 扩展 python
- paip.java 架构师之路以及java高级技术
- JavaScript的理解记录(1)
- AIX之ASM存储扩容
- scrollTop 鼠标往下移动到一定位置显示隐藏
- 一份高级Java招聘要求
- Linux基本配置
- hdu 5268 ZYB loves Score 水题
- hdoj 2544 最短路
- linux 信号处理
- Effective C++ 条款11
- iOS学习之NSAttributedString(富文本)
- 动态样式语言—LESS
- 学习JVM是如何从入门到放弃的?
- 百战程序员——Spring框架
- linux卸载openjdk
- Java 写一段字符到指定的文本文档中,如果该文本文档不存在,则创建该文本文档
- 洗礼灵魂,修炼python(20)--自定义函数(1)—基础概念
热门文章
- 利用for循环找出1000以内的质数
- 软件工程(C编码实践篇)学习心得
- Xamarin.Android通知详解
- C#开发奇技淫巧三:把dll放在不同的目录让你的程序更整洁
- 小丁带你走进git的世界四-重写历史记录
- 白板编程浅谈——Why, What, How
- golang的安装
- Atitit 输入法原理与概论ati use
- Atitti 载入类的几种方法    Class.forName ClassLoader.loadClass  直接new
- es6 新特性2