non-aggregate type error?

T

Timothee Groleau

Hi,

Could someone tell me what's wrong with this test case based on the compiler
error I get?

==============
class MyClass
{
private:
int i;
public:
void f() {};
};

int main()
{
MyClass c();
c.f();
}

==============

compiler (gcc 3.3.6) output:
==============
test.cpp: In function `int main()':
test.cpp:12: error: request for member `f' in `c', which is of
non-aggregate type `MyClass ()()'
==============

Thanks,
Tim.
 
I

Ian Collins

Timothee said:
Hi,

Could someone tell me what's wrong with this test case based on the compiler
error I get?

==============
class MyClass
{
private:
int i;
public:
void f() {};
};

int main()
{
MyClass c();
MyClass c;

The compiler thinks your version is a forward declaration of a function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top