BUG: C2248 When Access Protected Nested Class in Derived ClassLast reviewed: July 24, 1997Article ID: Q122370 |
The information in this article applies to:
SYMPTOMSIn the sample code in this article, class C2 is derived from C1, and contains nested class S2, which is derived from nested class S1, declared in class C1. Compiling the sample code results in the following compiler error:
error C2248: 'S1' : cannot access protected class declared in class 'C1' RESOLUTIONDeclare nested class C1::S1 as public.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONReferencing nested class S1 inside of the class C2 declaration does not create a problem, but deriving from it does. Also note that you have to include the base class name for the declaration of the derived nested class (C1::S1). That should not be required, but omitting to do so prevents the compiler from recognizing the nested class from the base class as a valid class name.
Sample Code
/* Compile options needed: none */ class C1 { protected: class S1 { }; }; class C2 : public C1 { S1 s1; class S2 : public C1::S1 // this line generates C2248 error { }; }; |
Additional query words: 8.00 8.00c 9.00 10.00 10.10 10.20 buglist1.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |