const_cast
-
Hi ! I'm facing many problems (app crashs) when my app is compiled in release mode (problems I don't have in debug mode). I noticed that removing some const_cast improved the situation. This makes me wonder : am I allowed to use const_cast ? How can I spot the situations where const_cast should be avoided ? If const_cast is dangerous, why is it provided ? Thanks for your enlightment ! Jerome
-
Hi ! I'm facing many problems (app crashs) when my app is compiled in release mode (problems I don't have in debug mode). I noticed that removing some const_cast improved the situation. This makes me wonder : am I allowed to use const_cast ? How can I spot the situations where const_cast should be avoided ? If const_cast is dangerous, why is it provided ? Thanks for your enlightment ! Jerome
hian So Jerome BAck!!!! so any way here you's Answer,As MSDN states that,i have maked sentence bold which might be causing problem in your program pointer to any object type or a pointer to a data member can be explicitly converted to a type that is identical except for the const, volatile, and __unaligned qualifiers. For pointers and references, the result will refer to the original object. For pointers to data members, the result will refer to the same member as the original (uncast) pointer to data member. Depending on the type of the referenced object, a write operation through the resulting pointer, reference, or pointer to data member might produce undefined behavior. ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk