Article ID: 122370 - Last Review: July 5, 2005 - Revision: 1.1 BUG: C2248 When Access Protected Nested Class in Derived ClassThis article was previously published under Q122370 On This PageSYMPTOMS
In 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'
RESOLUTION
Declare nested class C1::S1 as public.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. MORE INFORMATION
Referencing 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 CodeAPPLIES TO
| Article Translations
|
Back to the top
