www.digitalmars.com         C & C++   DMDScript  

c++ - default initialization of struct members

Hi,

AFAIK, the following test-program should initialize a.i with 0 (see the C++ 
standard: 8.5 Initializers [dcl.init] (7) An object whose initializer is an 
empty set of parentheses, i.e., (), shall be default-initialized.)


  #include <stdio.h>

  struct A
  {
    A()
    : i()
    { }

    int i;
  };

  int main(int argc, char *argv[])
  {
    A a;
    printf("%d\n", a.i);
    return a.i;
  }


bye, Christof
Jan 09 2002