I tried a Google search for it but didn't come up with anything. Does anyone know if this can be done? If not is there an elegant work around this?
Update: I think Frank Osterfeld's answer is the most clear solution. Thanks for all the other answers, I've upvoted your answers.
As others said, you cannot redeclare an enum (in which context, which one should be used anyway?).
If you just need some constants, and want extend them for a special case, you can use multiple enum declarations, one extending the other and then use ints to hold the values:
enum Error { NoError=0, AllIsBroken, WhatTheHellAreYouDoing, UserDefinedError };
enum NetworkError { HostNotFound=UserDefinedError+1, ConnectionTimeout, ... };
int error = HostNotFound;
if ( error == NoError )
...
if ( error == HostNotFound )
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With