Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?
From: Rob Vermeulen (rpvermeulen_at_tiscali-antispam-.nl)
Date: 04/09/04
- Next message: SaltPeter: "Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?"
- Previous message: Dave: "Interesting vector<> error in 6.0"
- In reply to: Pete Becker: "Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?"
- Next in thread: SaltPeter: "Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 9 Apr 2004 21:26:09 +0200
That was easy :-)
Much easier than the posting about using "++i" instead of "i++". :-)
Although I must say that I too happen to make such mistakes sometimes
(forgetting the second '=').
That is just the problem of knowing too much programming languages (or any
languages whatsoever). The brain sometimes mixes up the synthaxes :-)
I think I'll use the "NULL==..." version alot more now :-)
Anyway, thanks Peter!
"Pete Becker" <petebecker@acm.org> wrote in message
news:4076B2BB.9E8F488B@acm.org...
> Rob Vermeulen wrote:
> >
> > In several SDK examples of MS I notice the following.
> > To compare a pointer with NULL they do: "NULL == pMyPointer"
> > Why not just the other way around, like every "C++ for dummies" book
> > describes? :-)
> >
>
> Some people worry that they might leave out the second '=' sign and that
> their testing isn't adequate to find such a mistake. Writing the test
> backwards turns this mistake into an error.
>
> --
>
> Pete Becker
> Dinkumware, Ltd. (http://www.dinkumware.com)
- Next message: SaltPeter: "Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?"
- Previous message: Dave: "Interesting vector<> error in 6.0"
- In reply to: Pete Becker: "Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?"
- Next in thread: SaltPeter: "Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|