它是什么意思当你得到一个编译错误“看起来像一个函数定义”为类声明? [英] What does it mean when you get a compile error "looks like a function definition" for a class declaration?
问题描述
我最近遇到这个问题。我发现很多人提出问题的例子,在这里,例如—但没有具体的答案
I recently encountered this problem. I found many instances of people asking the question—here, for example—but no concrete answers.
下面是从该链接中提取的示例代码:
Here's the sample code hoisted from that link:
class AFX_BASE_APPLICATION_APP_CLASS CFileExtension
{
public:
CFileExtension ();
virtual ~CFileExtension ();
};
生成的错误是:
c:\FileExtension.h(14):error C2470:'CFileExtension':看起来像一个函数定义,但没有形式参数列表;跳过外观体 c>
推荐答案
你几乎肯定错过了定义 AFX_BASE_APPLICATION_APP_CLASS
。在这种情况下,它将通过未经改变的方式传递,VC ++将假定 CFileExtension
是返回 class AFX_BASE_APPLICATION_APP_CLASS
的函数。
You've almost certainly missed the header which defines AFX_BASE_APPLICATION_APP_CLASS
. In that case, it would be passed through unaltered and VC++ would assume that CFileExtension
was a function that returned class AFX_BASE_APPLICATION_APP_CLASS
.
因为它认为它是一个函数,它还认为它需要括号。
And, since it thinks it's a function, it also thinks it needs parentheses.
找到 AFX_BASE_APPLICATION_APP_CLASS
已定义, #include
该文件。
这篇关于它是什么意思当你得到一个编译错误“看起来像一个函数定义”为类声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!