From -1935017460308067426
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,f1dec9ce20a9c98f
X-Google-Attributes: gidf78e5,public
From: James.Kanze@dresdner-bank.com
Subject: Re: null pointers (was: Why's of C++ -- Part 1)
Date: 1999/08/23
Message-ID: <7prf8u$up8$1@nnrp1.deja.com>#1/1
X-Deja-AN: 516306318
Content-Transfer-Encoding: quoted-printable
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <7opqvm$vpa$1@news.hal-pc.org> <37B7C714.44E4EFB4@lucent.com> <7pcoem$105@abyss.West.Sun.COM> <7pdh80$qaf$1@engnews1.eng.sun.com> <7phdj7$4oj@abyss.West.Sun.COM> <2yG4gOAhsRv3EwJN@robinton.demon.co.uk>
X-Original-Date: Mon, 23 Aug 1999 12:36:47 GMT
Content-Type: text/plain; charset=iso-8859-1
X-Http-User-Agent: Mozilla/4.06 [de] (WinNT; I)
X-Complaints-To: news@news.unimelb.edu.au
X-Http-Proxy: 1.0 x27.deja.com:80 (Squid/1.1.22) for client 193.194.7.84
X-Trace: izvestia.its.unimelb.edu.au 935440619 26933 128.250.29.17 (23 Aug 1999 20:36:59 GMT)
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Mon Aug 23 12:36:47 1999 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN8GwxeEDnX0m9pzZAQF/nQF+Iy2PHvAfDUDBHBOLgrY3bKLZK0hiXHbO MNB+itRT/S4ZrHGnoHZzR+DC5EwLHRUr =9mo7
X-MyDeja-Info: XMYDJUIDkanze
Mime-Version: 1.0
NNTP-Posting-Date: 23 Aug 1999 20:36:59 GMT
X-MIME-Autoconverted: from 8bit to quoted-printable by ncar.UCAR.EDU id GAA07677
Newsgroups: comp.std.c++

In article <2yG4gOAhsRv3EwJN@robinton.demon.co.uk>,
  Francis Glassborow <francisG@robinton.demon.co.uk> wrote:
> In article <7phdj7$4oj@abyss.West.Sun.COM>, Stanley Friesen
[Contractor]
> <stanley@West.Sun.COM> writes
> >The example I was actually objecting to was using a *variable* of
> >type int that happened to have the value zero.  THAT I find
> >unacceptable.  And it is certainly not allowed in C, so there is no
> >reason from compatibility to accept it in C++.

> A further problem has just occurred to me.  Given an overload set
> including f(int) and f(char *) how do I pass the value of the null
> pointer constant to the second one?

You don't, of course.  Any more than you pass any other literal to a
function in general.  A value is passed to the function, but whether
that value is the result of a literal or not, there is no way for the
function to tell.

You can, of course, pass a null pointer to the function.

> f(0) resolves in a call to f(int)
> f((void *)0) falls foul of there being no conversion
> f((char *)0) may seem correct but it is not the null pointer constant
> and can be coded differently (and, I believe, actually is on some
> debugging implementations).

When you say "coded differently", what do you mean.  The expression
"(char*)0" is a null pointer, and must be coded as such.

> It seems to me that C++ provides no standard conforming mechanism to
> pass a null pointer constant to f(char *) in the presence of any
> version of f that can take an integer type argument.

A null pointer constant is a compile time construct, and has no meaning
at run time.  You can pass a null pointer to the function, and that is
all that counts.

--
James Kanze                   mailto: James.Kanze@dresdner-bank.com
Conseils en informatique orient=E9e objet/
                  Beratung in objekt orientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



