Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!cerc.utexas.edu!lynch From: lynch@cerc.utexas.edu (Tom Lynch) Newsgroups: comp.lang.c++ Subject: Re: inline member functions returning a enumerated type Message-ID: <1990Jul28.013049.9684@cerc.utexas.edu> Date: 28 Jul 90 01:30:49 GMT References: <1851@island.uu.net> <1990Jul27.083837.2078@cerc.utexas.edu> <10589@batcomputer.tn.cornell.edu> <1990Jul27.234044.8701@cerc.utexas.edu> Sender: root@cerc.utexas.edu (Operator) Distribution: na Organization: University of Texas at Austin Lines: 55 In article <1990Jul27.234044.8701@cerc.utexas.edu> lynch@cerc.utexas.edu (Tom Lynch) writes: >In article <10589@batcomputer.tn.cornell.edu> lijewski@tcgould.tn.cornell.edu (Mike Lijewski) writes: >>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. >> >... >> >>/****** EXAMPLE ******/ >> >>enum S { A, B, C }; >> >>int >>main() >>{ >> int S; >> S s; // this is an error; must be 'enum S s;' >> >> return 0; >>} >> >> > mike, I tried your example: > >enum S {A,B,C}; >int >main() >{ > int S > enum S s; > > return 0; >} > >and got: > My God! it compiles fine with a ';' my mistake. I am very embarrassed - please excuse the posting. -tom