This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C++ static integer class constants...
- From: John Love-Jensen <eljay at adobe dot com>
- To: John Ratliff <webmaster at technoplaza dot net>, MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Mon, 17 Oct 2005 07:03:20 -0500
- Subject: 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