FIX: Cannot Access Private Member from Friend ClassLast reviewed: September 18, 1997Article ID: Q115854 |
7.00 | 1.00 1.50 | 1.00
MS-DOS | WINDOWS | WINDOWS NTkbtool kbfixlist kbbuglist The information in this article applies to:
The Microsoft C/C++ Compiler (CL.EXE) included with:
- Microsoft Visual C++ for Windows, versions 1.0 and 1.5
- Microsoft Visual C++ 32-bit Edition, version 1.0
SYMPTOMSWhen compiling the code below, the C/C++ compiler will incorrectly report the following error:
C2248: 'ptr' : cannot access private member declared in class 'X' STATUSMicrosoft has confirmed this to be a bug in the products listed at the beginning of this article. This problem was corrected in Visual C++ version 2.0.
MORE INFORMATIONThe following sample can be used to demonstrate this problem.
Sample Code
/* Compile options needed: none */ #include <iostream.h>class C { class X;
class Y;
class X
{
X* ptr;
friend Y;
};
class Y
{
X* x;
public:
X* lookat() { return x->ptr; } /* Error: C2248 */
};
};
void main( void ){ cout << "PASSED" << endl;}
|
Additional reference words: 1.00 1.50 7.00 8.00 8.00c
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |