以下は、オブジェクトを定義していると思っていても、実際には関数を宣言している言語初心者によくあるタイプミスです。
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 ()
。