Tuesday, October 28, 2008

c: designated initializers for structures

c99 came with a feature of designated initializers.
A designated initializer, or designator, points out a particular element to be initialized. A designator list is a comma-separated list of one or more designators.

    int a; 
    int b; 
    int c; 
} s = {.a = 1, .c = 2};
Unfortunately c++ doesn't have this very handy feature.

No comments: