C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reference + initialiser oddity.

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Glen Able
Guest





PostPosted: Fri Jan 28, 2005 2:35 pm    Post subject: Reference + initialiser oddity. Reply with quote



Kindly consider:

struct MyStruct
{
Foo* foo;
Bar& bar;
};

void Blah(Foo* foo, Bar& bar)
{
// create+initialise struct
MyStruct m = {foo, bar};
}


This works fine on a gcc port. However vc6/.net give this cryptic error:
'm' : non-aggregates cannot be initialized with initializer list.

It appears that it's the Bar& that's the problem, not the Foo*. Anyone able
to shed light on this for me?

thanks,
G.A.


Back to top
Victor Bazarov
Guest





PostPosted: Fri Jan 28, 2005 2:45 pm    Post subject: Re: Reference + initialiser oddity. Reply with quote



Glen Able wrote:
Quote:
Kindly consider:

struct MyStruct
{
Foo* foo;
Bar& bar;
};

void Blah(Foo* foo, Bar& bar)
{
// create+initialise struct
MyStruct m = {foo, bar};
}


This works fine on a gcc port. However vc6/.net give this cryptic error:
'm' : non-aggregates cannot be initialized with initializer list.

It appears that it's the Bar& that's the problem, not the Foo*. Anyone able
to shed light on this for me?

VC++ has problems with brace-enclosed initialisers for aggregates.
The behaviour is somewhat fixed in the version 7.1 (I checked).

V

Back to top
Glen Able
Guest





PostPosted: Fri Jan 28, 2005 3:36 pm    Post subject: Re: Reference + initialiser oddity. Reply with quote




"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> wrote

Quote:
Glen Able wrote:
Kindly consider:

struct MyStruct
{
Foo* foo;
Bar& bar;
};

void Blah(Foo* foo, Bar& bar)
{
// create+initialise struct
MyStruct m = {foo, bar};
}


This works fine on a gcc port. However vc6/.net give this cryptic
error:
'm' : non-aggregates cannot be initialized with initializer list.

It appears that it's the Bar& that's the problem, not the Foo*. Anyone
able
to shed light on this for me?

VC++ has problems with brace-enclosed initialisers for aggregates.
The behaviour is somewhat fixed in the version 7.1 (I checked).


Right, so my code's all good and legal - hurrah!

thanks,
G.A.



Back to top
Ioannis Vranos
Guest





PostPosted: Sat Jan 29, 2005 1:21 am    Post subject: Re: Reference + initialiser oddity. Reply with quote

Glen Able wrote:

Quote:
struct MyStruct
{
Foo* foo;
Bar& bar;
};

void Blah(Foo* foo, Bar& bar)
{
// create+initialise struct
MyStruct m = {foo, bar};
}


This works fine on a gcc port. However vc6/.net give this cryptic error:
'm' : non-aggregates cannot be initialized with initializer list.

It appears that it's the Bar& that's the problem, not the Foo*. Anyone able
to shed light on this for me?


Your code compiles with VC++ 7.1. Provided that I provide a definition
for both Foo and Bar.




--
Ioannis Vranos

http://www23.brinkster.com/noicys

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.