FIX: C++ Compiler Treats &array[][] as 2-D Array of References (115708)
The information in this article applies to:
- Microsoft C/C++ for MS-DOS 7.0
- Microsoft Visual C++ 1.0
- Microsoft Visual C++ 1.5
This article was previously published under Q115708 SYMPTOMS
Attempting to call a class constructor using a reference to a two
dimensional array of objects will cause the compiler to incorrectly treat
the array as a two dimensional array of references. In the sample below,
the following errors will be incorrectly generated:
test.cpp(6) : error C2234: arrays of references are illegal
test.cpp(6) : error C2511: '__ctor' : overloaded member function
not found in 'X'
CAUSE
The compiler is interpreting
int (&iref)[10][10];
as if it was written:
int & iref[10][10];
It is not legal in C++ to use a pointer to a reference, so an array
of references is also not legal.
STATUS
Microsoft has confirmed this to be a bug in the C/C++ compiler for MS-DOS,
versions 7.0, 8.0, and 8.0c and the 32-bit C/C++ compiler, version 8.0.
This problem was corrected in compiler version 9.0, included with Visual
C++ version 2.0.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbbug kbCompiler kbCPPonly kbfix KB115708 |
---|
|