Subj : Re: structure initialization? To : borland.public.cpp.borlandcpp From : Bruce Salzman Date : Tue Sep 21 2004 09:34 pm "John Jennings" wrote in message news:4150839a$1@newsgroups.borland.com... > Hi, > Can anyone tell me the C++ standard for structure initialization? > When a structure is instantiated, are the items automatically > initialized > according to their definition, or are they left undefined? > Thanks, > John > Not sure what you mean by "according to their definition". But for example: struct MyStruct{ int a; bool b; float c; }; MyStruct A; A.a, A.b, A.c will contain garbage unless you're explicit: MyStruct A={ 1, false, 3.141}; You can also get away with memset(&A, 0, sizeof(A)); Regards, Bruce .