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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux