Afficher un message
Vieux 06/12/2007, 14h31   #13
anon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: deriving a class - extending enum

ManicQin wrote:
> On Dec 6, 10:44 am, anon <a...@no.no> wrote:
>> werasm wrote:
>>> On Dec 5, 10:59 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
>>>> werasm wrote:
>>>>> On Dec 5, 10:53 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
>>>>>> werasm wrote:
>>>>>>> On Dec 5, 10:39 pm, "Alf P. Steinbach" <al...@start.no> wrote:
>>>>>>>> Don't use enums.
>>>>>>> Never?
>>>>>> Of course never.
>>>>> Well, care to give some reasons and alternatives?
>>>> Read Alf's response. I totally agree with him on his suggestions.
>>> I've read his response, hence my question (Never, or never for
>>> the particular problem). The question still remains.

>> I think they said never use enums to check errors. Or, have I misunderstood?
>>
>> You can make a base error class, from which all other error classes
>> inherits. Then it is easy to add error codes by just adding classes
>> together with derived classes. When error occurs, throw an error class

>
> But is'nt throwing an error class is much much heavier than returning
> an enum?


Yes, but only in a case when an error happens.

> I dont see any usability/readability benefits in throwing exceptions
> over returning error codes.


You do not have to check error codes whenever you call functions,
therefore code is much cleaner
  Réponse avec citation
 
Page generated in 0,04988 seconds with 9 queries