Problem with object initialization

Rodolfo Schulz de Lima rodolfo@rodsoft.org
Fri Feb 22 20:33:00 GMT 2008


Hi, I'd like to know why this rather simple code doesn't compile on gcc 
(from 4.2 to 4.3, haven't tested on earlier compilers):

struct data {};

class test
{
public:
     test(data) {}
     int member;
};

int main()
{
     test a(data());
     a.member = 3;
}

The error output is:
  error: request for member ‘member’ in ‘a’, which is of non-class type 
‘test ()(data (*)())’

Now... why the compiler assumed that I'm defining a function returning 
'test' and accepting a pointer to a function returning 'data'? If I 
wanted this, I'd write: test a(data(*)()), isn't it? What's the catch?

Regards,
Rodolfo Lima.



More information about the Gcc mailing list