sher@rochester.ARPA (David Sher) (05/25/86)
I just tripped over another "feature" of c++. This feature is that enums are not types. They look like types but really are synonomous with sets of constant definitions and typedefs of ints. This strikes me as wrong. Consider this c++ file: enum footype { FOO = 17 }; void bar ( footype g ); void foo ( footype f ) { bar ( 13 ); } overload baz; void baz ( footype h ); void baz ( int i ); class myclass { int k; public: myclass ( footype f ); myclass ( int i ); ~myclass ( ) { ; } }; First I think it is wrong that c++ accepts the statement bar ( 13 ) as good. If bar takes footype's it should not take arbitrary integers. Note also that the compiler accepts the definition of baz but refuses the constructor definition of the class. This seems very odd because either both baz and myclass is ambiguous or both are unambiguous so the compiler should accept both or reject both. I know the language is defined this way but the compiler should at least give warnings when "type violations" of this sort occur. -- -David Sher sher@rochester seismo!rochester!sher
ark@alice.UucP (Andrew Koenig) (05/25/86)
> I just tripped over another "feature" of c++. > This feature is that enums are not types. > They look like types but really are synonomous with sets of > constant definitions and typedefs of ints. This strikes me as wrong. Maybe so, but that's how C does it and C++ is just trying to be compatible here.