The following is a cast:
int foo = (int) somefloat;
However, is this considered a cast?
int foo = int( somefloat );
More importantly, if there is a difference between the two, is the resulting compiled code different?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The second example is often called a function style cast and was added to C++ but there’s no difference between the two in terms of semantics/object code.
Here’s a good explanation of the reason that function style casts were added:
What exactly is or was the purpose of C++ function-style casts?