Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3426632
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:44:20+00:00 2026-05-18T06:44:20+00:00

everyone, I have some question about C++, what do You actually prefer to use

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:44:21+00:00Added an answer on May 18, 2026 at 6:44 am

    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:

    • There’s no accidental assignment
    • You’re testing the existence of something (ie. if it’s NULL). Hence, you can read the statement as “If var does not exist” or “If var is not set”
    • Maps closely to what you’d idiomatically write if var was a boolean (bools aren’t available in C, but people still mimic their use)
    • Similar to the previous point, it maps closely to predicate function calls, ie. if (!isEmpty(nodeptr)) { .. }
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

everyone I have some question about tasks in Linux, I know that all tasks
Good day everyone. I have a question about making and using derived classes of
Good morning everyone, I have a question about J2EE framework. since ASP.net 3.5 mvc
everyone. I have some labels that I draw them in the xib file, and
Hello everyone, I have some confusion regarding some Win32 API data types and macros
I have a windows service that does some intensive work every one minute (actually
Hello everyone I want to ask a question about including guards in C programming.
HI, everyone, I want to ask a question about the iPhone application. I am
the title might be too generic, but I have a very specific question about
When changes occur on some reservation I want everyone involved getting a mail about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.