Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ();
};

The error this generates is:

c:\FileExtension.h(14) : error C2470: 'CFileExtension' : looks like a function definition, but there is no formal parameter list; skipping apparent body

like image 993
Tim Keating Avatar asked Mar 26 '09 06:03

Tim Keating


1 Answers

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.

You just need to find where AFX_BASE_APPLICATION_APP_CLASS is defined and #include that file.

like image 60
paxdiablo Avatar answered Oct 13 '22 01:10

paxdiablo