Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ames!pacbell.com!tandem!zorch!ditka!tsisj1!hg From: hg@tsisj1.UUCP (Heinrich Gantenbein) Newsgroups: comp.lang.c++ Subject: Re: inline member functions returning a enumerated type Message-ID: <230@tsisj1.UUCP> Date: 28 Jul 90 00:04:12 GMT References: <1851@island.uu.net> <58170029@hpclmao.HP.COM> Sender: news@tsisj1.UUCP Organization: Thermco Systems, Inc., San Jose, California Lines: 42 In article <58170029@hpclmao.HP.COM> mao@hpclmao.HP.COM (Mike Ogush) writes: >> / hpclmao:comp.lang.c++ / chris@island.uu.net (Chris King) / 10:31 am Jul 23, 1990 / >> [asks for help on inline enum id foobar () {return v;} >> "TestClass.cc", line 8: error: bad base type: inline enum id >parser objects to "inline enum id" as a valid type. In any case, I >modified your code to rename the "enum id" type using typedef and the code >compiled fine. > >Fixed version: > >struct test { > typedef enum id { A, B, C } ID; > > ID v; > > test() { v = A; } > inline ID GetV() { return v; } > >}; [rest deleted] An enum tag under C++ is already a typedef so the above is redundancy (both the original and the CORRECTED version. A look at c_varieties.h in at least the SUN version of C++ 2.0 indicates that specifying enum my_type my_func (... as illegal. They provide a macro to deal with the differences: -- start of included segment from comment section of that file -- * enum type specifier: * In K&R C, it is OK to use "enum xyz" as return type but in C++, * one should use "xyz". ENUM_TYPE macro is used to handle this. * * ENUM_TYPE(enum, xyz) (*func) (...); -- end -- I hope this helps. And please do not use typedefs to dupplicate one of the great features of C++ :-). -- -- Heinrich Gantenbein, Software Consultant: I'd rather be sailing. hg@tsisj1.uucp ..!apple!ditka!tsisj1!hg ...!mips!daver!ditka!hg