Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > non-aggregate type error?

Reply
Thread Tools

non-aggregate type error?

 
 
Timothee Groleau
Guest
Posts: n/a
 
      04-27-2006
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.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      04-27-2006
Timothee Groleau wrote:
> 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.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Timothee Groleau
Guest
Posts: n/a
 
      04-27-2006
Ian Collins wrote:

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


Ha understood, thanks!
Tim.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
type(d) != type(d.copy()) when type(d).issubclass(dict) kj Python 5 12-26-2010 06:48 PM
#define ALLOCIT(Type) ((Type*) malloc (sizeof (Type))) Yevgen Muntyan C Programming 10 02-13-2007 02:52 AM
type casting vs. type converting Toby VHDL 3 09-07-2005 01:42 PM
Re: Type casting- a larger type to a smaller type pete C Programming 4 04-02-2004 05:19 PM
Re: Type casting- a larger type to a smaller type heyo C Programming 3 04-01-2004 06:35 PM



Advertisments