【发布时间】:2013-11-13 18:56:41
【问题描述】:
下面的问题让我抓狂,虽然它看起来并不奇怪:
class Foo;
// This is the location of the first error code
// ↓
int (Foo::*)(int) getPointer()
{
return 0;
}
GCC 给我:
error: expected unqualified-id before ')' token
error: expected initializer before 'getPointer'
PS:我用 -std=c++11 编译
【问题讨论】:
-
看在上帝的份上使用 typedefs
-
@Slava 完全同意,但也很高兴了解它是如何工作的。
-
@Slava 我不能,因为返回类型取决于推导的模板参数,并且您不能在 'template' 和 'getPointer()' 之间进行 typedef
标签: c++ pointers gcc c++11 member-function-pointers