title: What is the C++ equivalent to C's designated initializers?
body: <p>You can declare a structure in C like so:</p>
  
  <pre><code>typedef struct MyStruct {
      const char *name;
      int (*func1)(void);
      int (*func2)(void);
      int (*func3)(void);
  } MyStruct;
  
  int test_func2(void) {
      return 0;
  }
  
  MyStruct test_struct = {
      .name   = "buffer",
      .func2  = test_func2,
  };
  </code></pre>
  
  <p>This is quite handy for only defining particular members, all the other ones being set to 0/NULL.</p>
  
  <p>Edit: in particular, this allows to not know the details of how MyStruct is defined, so it can change internally, adding new members etc.. without ever breaking code using this type.</p>
  
  <p>This wouldn't compile with a C++ compiler however, getting error:</p>
  
  <pre><code>test.c:23: error: expected primary-expression before ‘.’ token
  test.c:24: error: expected primary-expression before ‘.’ token
  </code></pre>
  
  <p>Is there an equivalent C++ declaration achieving the same?</p>
  
  <p>Thanks.</p>
  
  <p>Edit: @chris I can tell you don't understand :)
  And It's quite obvious that most other people commenting on what syntax I should have used, how the structure should have been defined etc.. have completely missed the point. This isn't about the correct way to define a structure, this snippet was only there to provide a context. </p>
  
  <p>As for code equivalence,
  Say somewhere in your code you did:</p>
  
  <pre><code>MyStruct blah = { NULL, NULL, func2 };
  </code></pre>
  
  <p>Now MyStruct change its definition to be:</p>
  
  <pre><code>typedef struct MyStruct {
    const char *name;
    int (*func4)(void);
    int (*func1)(void);
    int (*func2)(void);
    int (*func3)(void);
  } MyStruct;
  </code></pre>
  
  <p>Your code will still compile just fine, but has introduced a serious regression : instead of setting func2 like it used to, you would now initialise func1 member...</p>
  
  <p>The question was about is there C++ designated initializers equivalent: there isn't. problem closed.</p>