BUG: Access to Nested Base Class Member Functions BlockedLast reviewed: April 30, 1997Article ID: Q167749 |
The information in this article applies to:
SYMPTOMSWhen a class derived from a nested class calls a base class member function explicitly, the compiler generates error C2352: (relative to the sample code below):
main.cpp(13) : error C2352: 'A::B::f' : illegal call of non-static member function RESOLUTIONThere are 2 workarounds:
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Sample Code
/* Compile Options: None */ class A { public: class B { public: void f(); }; }; class C : public A::B { public: void g() { A::B::f(); } // <== C2352 at this line }; Workaround #1Call f() without the scope resolution operator:
class C : public A::B { public: void g() { f(); } };NOTE: This will not work if there is a C::f member function defined. If that is the case, use workaround #2.
Workaround #2Call A::B::f() via a pointer to member function:
class C : public A::B { public: void g() { void (A::B::* fp)() = A::B::f; (this->*fp)(); } }; |
Keywords : CPPLngIss kbprg vcbuglist500 kbbuglist
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |