Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!batcomputer!lijewski From: lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) Newsgroups: comp.lang.c++ Subject: Re: inline member functions returning a enumerated type Message-ID: <10589@batcomputer.tn.cornell.edu> Date: 27 Jul 90 19:26:04 GMT References: <1851@island.uu.net> <1990Jul27.083837.2078@cerc.utexas.edu> Reply-To: lijewski@tcgould.tn.cornell.edu (Mike Lijewski) Distribution: na Organization: Cornell National Supercomputer Facility Lines: 46 In article <1990Jul27.083837.2078@cerc.utexas.edu> lynch@cerc.utexas.edu (Tom Lynch) writes: >In this case 'id' is already an enum type, so adding the 'enum' in >front of it is erroneous. Also, one should not place the extra 'struct' in >front of structure types. Adding an "extra" enum (or any typename for that matter) is not erroneous. In fact, there are cases in C++ programming (see appended example) where you are be forced to write 'enum id' instead of just 'id'. >p309 of The C++ Programming Language by Bjarne Strouistup, r14, >Differences from C: > "The name of a class or enumeration is a type name" Very true. But unlike C, typenames and non-type names are in the same name space C++. So sometimes you must use the typename explicitely to differentiate between a typename and non-type name. >of the same book, Note to C Programmers >"The better on knows C, the harder it seems to avoid writing C++ in > C style ..." > >tom >lynch@cerc.utexas.edu If you're going to post quotes from books, please use E&S. /****** EXAMPLE ******/ enum S { A, B, C }; int main() { int S; S s; // this is an error; must be 'enum S s;' return 0; } -- Mike Lijewski (H)607/277-0394 (W)607/254-8686 Cornell National Supercomputer Facility ARPA: mjlx@eagle.cnsf.cornell.edu BITNET: mjlx@cornellf.bitnet SMAIL: 1122 Ellis Hollow Rd. Ithaca, NY 14850