BUG: Access to Nested Base Class Member Functions BlockedID: Q167749
|
When 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
There are 2 workarounds:
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
/* 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
};
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.
class C : public A::B {
public:
void g()
{
void (A::B::* fp)() = A::B::f;
(this->*fp)();
}
};
Additional query words:
Keywords : kbprg kbLangCPP kbVC kbVC500bug kbVC600bug
Version : winnt:5.0,6.0
Platform : winnt
Issue type : kbbug
Last Reviewed: May 14, 1999