Microsoft KB Archive/115854

= FIX: Cannot Access Private Member from Friend Class =

Article ID: 115854

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 1.0 Professional Edition

-



This article was previously published under Q115854



SYMPTOMS
When compiling the code below, the C/C++ compiler will incorrectly report the following error:

C2248: 'ptr' : cannot access private member declared in class 'X'



STATUS
Microsoft 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 INFORMATION
The following sample can be used to demonstrate this problem.

Sample Code
/* Compile options needed: none

class C { class X;  class Y;
 * 1) include 

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 query words: 1.00 1.50 7.00 8.00 8.00c

Keywords: kbbug kbfix kbcpponly kbcompiler KB115854

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.