Article View: gnu.g++
Article #488Enumeration Problem (Simple)
From: Bala Rajaraman
Date: Fri, 05 Jan 1990 02:17
Date: Fri, 05 Jan 1990 02:17
34 lines
1281 bytes
1281 bytes
Stroustrup's C++ book indicates that if in a switch only a few of the
enumerated values are handled the compiler issues a warning [pg. 64-65].
In the following program the g++ compiler neither issues a warning,
nor does it prevent me from assigning an arbitrary value to a variable of
an enumerated type.
-------------------------------------------------------------------------
#include <stdio.h>
#include <stream.h>
main()
{
enum keys {ASM,AUTO,BREAK};
keys key;
key = 4;
switch (key) {
case ASM:
break;
case AUTO:
break;
}
cout << "KEY = " << key << "\n";
}
-------------------------------------------------------------------------
Is this feature not available in g++ ??
If this is a trivial question, I apologize. I do not have the
GNU G++ User Guide as yet.
Thanks
Bala
:-)
rajarar@hubcap.clemson.edu
Technical Details
Message-ID:
<7570@hubcap.clemson.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!caesar.cs.montana.edu!ogicse!emory!hubcap!rajararShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!caesar.cs.montana.edu!ogicse!emory!hubcap!rajarar From: rajarar@hubcap.clemson.edu (Bala Rajaraman) Newsgroups: gnu.g++ Subject: Enumeration Problem (Simple) Keywords: Switch, Enumeration Message-ID: <7570@hubcap.clemson.edu> Date: 5 Jan 90 02:17:32 GMT Distribution: na Organization: Clemson University, Clemson, SC Lines: 34