This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ static integer class constants...


Hi John,

To get the behavior you want without having to define the static class
constant in some translation unit, use an anonymous enum:

class foo {
public:
  enum { X = 5, Y = 10, Z = 15 };
};

>Is this correct behavior?

I believe your example demonstrates the correct behavior.

In that *IF* you specify the value of a static const int in the declaration,
that both you *MUST* define the static const int in one-and-only-one
translation unit, and you *MUST NOT* specify the initialization value in
that definition.

HTH,
--Eljay



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]