everyone, I have some question about C++, what do You actually prefer to use
int* var = 0;
if(!var)...//1)
or
if(var == 0)..//2)
what are the pros and cons? thanks in advance
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.
I’ve always been taught to use
if (!var), and it seems that all the idiomatic C(++) I’ve ever read follows this. This has a few nice semantics:vardoes not exist” or “If var is not set”varwas a boolean (bools aren’t available in C, but people still mimic their use)if (!isEmpty(nodeptr)) { .. }