Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!yale!cmcl2!rna!kc From: kc@rna.UUCP (Kaare Christian) Newsgroups: comp.lang.c++ Subject: const enums -- Lawyers opinions?? Keywords: const, enum Message-ID: <963@rna.UUCP> Date: 8 Jan 90 13:56:23 GMT Organization: Rockefeller University - Neurobiology Lines: 21 Hey there language lawyer types... I ran across the following while using Zortech C++ 2. The behavior seems wrong to me, but I couldn't decide from the ugly reddish manual what was the correct behavior. In the following example, my intent is to declare a constant enum by or'ing together some enum constants. What I discovered with ZTC is that I can only do this if I cast each of the enum values to const. Since enum values are already constants (but not "const", it seems), this seems burdensome. Is this a Zortechism, or is this standard C++ behavior? enum bits { zero = 1, one = 2, two = 4 }; bits ZeroAndOne = zero | one; // OK const bits OneAndTwo = one | two; // Fails with ztc2.01 // complaint is type mistmatch, had and const bits OneAndTwoAgain = (const bits)one | (const bits)two; // OK // but casts on the right look very redundant