Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #81601
| From | Bo Persson <bo@bo-persson.se> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: NULL versus 0 |
| Date | 2021-09-26 13:54 +0200 |
| Message-ID | <irb5brF7b6gU1@mid.individual.net> (permalink) |
| References | <21138a34-469b-4c7a-9ef1-e9307ba52673n@googlegroups.com> <c52e136c-17bb-4eb4-8407-891571d9ef92n@googlegroups.com> <slrnsl06g7.5o3.grahn+nntp@frailea.sa.invalid> <aAV3J.57544$2Q_3.32321@fx35.iad> |
On 2021-09-26 at 09:47, Branimir Maksimovic wrote: > On 2021-09-26, Jorgen Grahn <grahn+nntp@snipabacken.se> wrote: >> On Sat, 2021-09-25, see.my....@gmail.com wrote: >>>> int *pInt = 0; >>>> >>>> Nothing inherently wrong with that, but in C, it would be more >>>> traditional to use NULL. >>> >>> It would be more traditional in C++, as well. >> >> Opinions varied. Before nullptr, I always used NULL in C and 0 in >> C++. IIRC using 0 was a common recommendation here, too, for whatever >> reason. > > #define NULL (void*)0 > simple, problem is that in C++, one have to cast from void > and that does not works, and this is BuG in C++. > > It is not a bug when it is done very much on purpose. Stroustrup says: "A pointer to any type of object can be assigned to a variable of type void*, a void* can be assigned to another void*, void* can be compared for equality and inequality, and a void* can be explicitly converted to another type. Other operations would be unsafe because the compiler cannot know what kind of object is really pointed to. Consequently, other operations result in compile-time errors."
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
NULL versus 0 "das...@gmail.com" <dashley@gmail.com> - 2021-09-25 11:03 -0700
Re: NULL versus 0 Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-09-25 18:16 +0000
Re: NULL versus 0 Paavo Helde <myfirstname@osa.pri.ee> - 2021-09-25 21:20 +0300
Re: NULL versus 0 Paavo Helde <myfirstname@osa.pri.ee> - 2021-09-25 21:32 +0300
Re: NULL versus 0 "das...@gmail.com" <dashley@gmail.com> - 2021-09-25 12:08 -0700
Re: NULL versus 0 Juha Nieminen <nospam@thanks.invalid> - 2021-09-27 05:47 +0000
Re: NULL versus 0 Bo Persson <bo@bo-persson.se> - 2021-09-27 08:32 +0200
Re: NULL versus 0 "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-09-26 23:37 -0700
Re: NULL versus 0 "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2021-09-27 10:32 +0200
Re: NULL versus 0 Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-27 11:32 -0700
Re: NULL versus 0 James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-09-27 15:03 -0400
Re: NULL versus 0 "see.my....@gmail.com" <see.my.homepage@gmail.com> - 2021-09-25 13:05 -0700
Re: NULL versus 0 Jorgen Grahn <grahn+nntp@snipabacken.se> - 2021-09-26 06:58 +0000
Re: NULL versus 0 Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-09-26 07:47 +0000
Re: NULL versus 0 Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-26 02:15 -0700
Re: NULL versus 0 Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-09-26 09:38 +0000
Re: NULL versus 0 Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-26 15:03 -0700
Re: NULL versus 0 Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-09-29 02:29 +0000
Re: NULL versus 0 Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-28 20:34 -0700
Re: NULL versus 0 David Brown <david.brown@hesbynett.no> - 2021-09-29 08:52 +0200
Re: NULL versus 0 Bo Persson <bo@bo-persson.se> - 2021-09-26 13:54 +0200
Re: NULL versus 0 Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-26 15:17 -0700
Re: NULL versus 0 Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-09-29 02:26 +0000
Re: NULL versus 0 Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-26 02:17 -0700
Re: NULL versus 0 HorseyWorsey@the_stables.com - 2021-09-26 14:20 +0000
Re: NULL versus 0 James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-09-25 17:36 -0400
Re: NULL versus 0 "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-09-26 23:05 -0700
csiph-web