【发布时间】:2011-03-10 11:43:32
【问题描述】:
以下是语言新手常见的拼写错误,他们认为自己在定义一个对象,但实际上是在声明一个函数:
struct T
{
void foo() {}
};
int main()
{
T obj();
obj.foo();
}
GCC 4.1.2 的错误是:
In function 'int main()':
Line 9: error: request for member 'foo' in 'obj', which is of non-class type 'T ()()'
compilation terminated due to -Wfatal-errors.
为什么消息T ()()中报告的类型是?我期待T ()。
【问题讨论】:
标签: c++ gcc most-vexing-parse