Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Whats the best way to create a “#define macro” for “NULL” in C++?

best create null
0
Posted

Whats the best way to create a “#define macro” for “NULL” in C++?

0

The best way is: don’t do it. The most portable way to compare against the nil ptr is to compare against “0”. Some programmers use a #define to set NULL to “0”, but that can conflict with the way the standard libraries #define NULL. There is no portable way to define a “const” ptr called “NULL” that can be compared against any arbitrary ptr — the literal “0” is acceptable for this however.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123