When To Use static_cast as opposed to traditional methods
Posted on 1998-03-15
C++ introduced the use of new casting operators. In a book I am reading I have came across
static_cast as a way to convert types to other types. Previously I would use the following method of
while ((!isspace(pBuffer[location])) && ((unsigned int)location < strlen(pBuffer)))
Should I abandon the above method of casting for the static_cast method used
while ((!isspace(pBuffer[location])) && (static_cast<unsigned int>(location) < strlen(pBuffer)))
What are the advantages of using static_cast as opposed to direct casting as
in the first line of code? Are there any advantages to using the former casting method I was used to.
Thanks For The Input.