Type of pointer to member from base class
问题 I have a problem regarding member pointers. The following code fails to compile using both Oracle Solaris Studio 12.2's CC and cygwin GCC 4.3.4 but works with Microsoft Visual C++ 2010: struct A { int x; }; struct B : public A { }; template<typename T> class Bar { public: template<typename M> void foo(M T::*p); }; int main(int, char *[]) { Bar<B> bbar; bbar.foo(&B::x); return 0; } At the next to last line both compilers mentioned above fail to find a match for Bar<B>::foo(int A::*) . I wrote