![]() |
Casting signed int to unsigned int?
I know I could use simple C casts (unsigned int uint_fld = (unsigned int) ivar;) but I'm not sure if I should use some of the handy casting functions (unsigned int uint_fld = dynamic_cast<unsigned int>(ivar);). Which should I chose?
sidequestion: I have countlessly just casting something unsigned through :
|
Re: Casting signed int to unsigned int?
Most c++ pureists would say that it is NOT appropriate for c++. IMO (for what its worth) I think it depends -- in your example it would be ok, but in more complex situations it would not. If you do use the c-style castings you must make sure you absolutely KNOW what you are doing because the compiler will simply assume you are correct -- no error checking. The compiler will produce warnings or error with c++ casts.
|
| All times are GMT -5. The time now is 3:49 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC