🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c++
Article #308

Re: (or does it?)

#308
From: Frank Adams
Date: Tue, 09 Sep 1986 23:54
26 lines
1856 bytes
In article <6021@alice.uUCp> bs@alice.UUCP writes:
>The general problem of which this problem with unsigned is a symptom is that
>C++'s resolution mechanism for overloaded functions cannot distinguish an
>``unsigned'' from an ``int''. For example, if one could declare
>
>	overload f(unsigned), f(int);
>
>which function would f(-1) call? which one would f(1) call? why?

From K&R, pg. 180 (Stroustrup has identical wording on pg. 246):

   A decimal constant whose value exceeds the largest signed integer is
   taken to be "long"; an octal or hexadecimal constant which exceeds the
   largest unsigned integer is likewise taken to be "long"; otherwise
   integer constants are taken to be "int".

Therefore, both "1" and "-1" are of type "int", and both "f(1)" and "f(-1)"
should invoke "f(int)".  If you want to invoke the other function using a
constant argument, try e.g. "f((unsigned) 1)".

There may be some point allowing a terminal "u" (or "U") to specify an
unsigned constant, so that "1u" would be of type "unsigned int"; but as
the example shows, this is not strictly necessary.

Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108
Technical Details
Message-ID: <1800@mmintl.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!styx!twg-ap!amdahl!hplabs!pesnta!amd!amdcad!amdimage!prls!philabs!pwa-b!mmintl!franka
References: <6021@alice.uUCp>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!styx!twg-ap!amdahl!hplabs!pesnta!amd!amdcad!amdimage!prls!philabs!pwa-b!mmintl!franka
From: franka@mmintl.UUCP (Frank Adams)
Newsgroups: net.lang.c++
Subject: Re: (or does it?)
Message-ID: <1800@mmintl.UUCP>
Date: Tue, 9-Sep-86 19:54:15 EDT
Article-I.D.: mmintl.1800
Posted: Tue Sep  9 19:54:15 1986
Date-Received: Sun, 14-Sep-86 03:34:27 EDT
References: <6021@alice.uUCp>
Reply-To: franka@mmintl.UUCP (Frank Adams)
Organization: Multimate International, E. Hartford, CT
Lines: 26