enums??

Pages: 12
closed account (Dy7SLyTq)
you probably shouldn't do python or php then :|
While I do prefer strong types, I was actually referring to type aliases themselves, and not types.
closed account (Dy7SLyTq)
oh sorry my mistake
> But it still is implicitly convertible to an int and not its own type, which is why I don't like it.

Yes; though it is no different from : int num_pages_in_a_book = 87 ;
Should the number of pages in a book be an int? Or even something that can be implicitly convertible to an int?

And what about double ambient_temperature = 24.7 ;
Should temperature be a double? Or even something that can be implicitly convertible to a double?

Does this (syntactically correct) expression make any sense? num_pages_in_a_book * ambient_temperature

Should we then be creating a plethora of user-defined types with no implicit conversion to arithmetic types to represent each entity that has an interpretation as a numeric value? class number_of_pages_in_a_book ; class temperature ; class cartesian_coordinate ; class age_of_a_person ; class return_value_of_main ; and so on?

As I see it, scoped enumerations are intended for use in situations where the concept involved does not have an interpretation as a numeric value.


> with scoped enums having their own type, you can do proper function overloading.

Unscoped enums also have distinct types; we can do function name overloading with them as well.
Topic archived. No new replies allowed.
Pages: 12