Topic: Allow initializers on static data members


Author: petergo@microsoft.UUCP (Peter GOLDE)
Date: 17 Aug 90 19:14:57 GMT
Raw View
One modification to the standard that I think would be useful would
be amend 9.4 to allow static data members to have initializers.  Such
data members would then have _internal_ linkage.  If multiple files define
the same data members, the initializers must be the same.

The advantages of this are:

1.  It is exactly parallel with declaring member functions inside a class
    definition; they also have internal linkage.

2.  Having the static member have internal linkage would prevent the
    problems noted in 9.4 of the ARM.  A single thing would not
    have multiple definitions.

3.  It would allow the construction below:

    class TABLE_OF_STUFF
    {
    ....
    private:
        static const int tablesize = 147;
        static const thetable[tablesize];
    };

    This cannot be accomplished by placing the initializer outside
    the class declaration as is now required.  With the current language
    definition, an enum is required to do this -- surely a perversion
    of the enum concept.

--Peter Golde
  uunet!microsoft!petergo
  petergo%microsoft@uunet.uu.net