Which of these should be used?
char *ex = new char[255];
// code
delete [] ex;
or
char *ex = new char[255];
// code
delete [] (char *) ex;
I’m thinking that the cast isn’t necessary, but would it have any effect on the actual deletion?
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.
You do not need to cast, The cast won’t have any effect anyways.
The C++ Standard does not need you to do any casting. Here is the reference.
Section §3.7.3.2.3: