Hi Saurabh
Thanks for the document. Please refer to start of page 214, Section 8.5.4
,point 3, Below is example from that
struct S2 {
int m1;
double m2, m3;
};
S2 s21 = { 1, 2, 3.0 }; // OK
S2 s22 { 1.0, 2, 3 }; error: narrowing
S2 s23 { }; // OK: default to 0,0,0
I tried the above case with
Here you go
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3337.pdf
The c++ standard itself. Refer to section 8.5.4 page no. 213.
Looks like even this int a[10] = {2} is not guaranteed to initialize all
the elements of the array. Sure gcc provides this but then it becomes a
compiler speci
Hi sagar
Actually its the compiler which is doing things for you.
GCC or G++ have some features that allows you to initialize array. For
example in your case 2 when you specify a single element gcc intializes the
whole array with 0. You can do this also:
Int arr [6]={[3]=0, [4]=5} p.s. gcc allows
Thanks Deepak and Rahul for the reply.
Do you guys have any standard document or any standard book which defines
this? I totally agree with these answers but I don't have any formal
written text.
In my example 1, the object is on stack and this lead to a1[0].z to be
un-initialized. But as the sp
http://stackoverflow.com/questions/3127454/how-do-c-class-members-get-initialized-if-i-dont-do-it-explicitly
On Sun, Sep 28, 2014 at 12:22 PM, Deepak Garg
wrote:
> Hi
>
> In example 1, member z will have a garbage value (i.e. 0 in your case )
>
> Thanks
> Deepak
> On Sep 28, 2014 11:29 AM, "saga
Hi
In example 1, member z will have a garbage value (i.e. 0 in your case )
Thanks
Deepak
On Sep 28, 2014 11:29 AM, "sagar sindwani" wrote:
> I am working on How compilers handle initialization list. I came across a
> case where I am not sure what should be the compiler behaviour.
>
> *Example 1