Article View: comp.std.c++
Article #624overloading and array reference arguments
From: Jim ADCOCK
Date: Thu, 06 Dec 1990 00:33
Date: Thu, 06 Dec 1990 00:33
40 lines
1612 bytes
1612 bytes
Can someone clarify for me the resolution of overloaded functions of
with array reference arguments? Seems to me that ARM says that
arrays do not suffer their common automatic conversion to a pointer to
their first element when assigned to a same-typed reference,
thus in the example below the three overloaded functions should be
called in turn, via a first level, "best match" trivial conversion
of a type to a reference to the same type? [But when I tried this on two
different compilers they both did strange, and differing things.]
This questions relates to my still trying to understand whether arrays
in C++ are exact types or not. My understanding is that are arrays in
C++ are [typically] exact types, that suffer auto-conversion to inexact type
[pointer to first member] in all "Classic C" schenerios, but not in
C++ -only schenerios?
#include <stdio.h>
typedef int V1[1];
typedef int V2[2];
typedef int V3[3];
extern int printf(const char*, ...);
void f(V1&) { printf("f(V1&)\n"); }
void f(V2&) { printf("f(V2&)\n"); }
void f(V3&) { printf("f(V3&)\n"); }
int main(int argc, char* argv[])
{
V1 v1;
V2 v2;
V3 v3;
f(v1);
f(v2);
f(v3);
return 0;
}
Technical Details
Message-ID:
<59595@microsoft.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!microsoft!jimadShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.std.c++ Subject: overloading and array reference arguments Message-ID: <59595@microsoft.UUCP> Date: 6 Dec 90 00:33:18 GMT Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 40