struct test
{
void f() {};
};
test t1;
using memfun_t = void (test::*)();
memfun_t mf = &test::f;
auto a1 = &test::f; // OK
auto a2 = t1.*mf; // error
auto a3 = &(t1.*mf); // still no
//#define NOT_WORKS
#define HOW(X) 0
struct A {
};
struct B {
A a;
};
struct C {
B b;
};
int main(int argc, char **argv) {
A B::*ba = &B::a; // ba is a pointer to B::a mem
假设我有这样的代码: #include <iostream>
struct Mine
{
int a;
int b;
};
int main()
{
int Mine::* memberPointerA = &Mine::a;
int Mine::* memberPointerB = &Mine::b;
std::cout