c++成员解引用运算符
·
class TEST{
public:
TEST(int v,int v2):a(v),b(v2){
}
int a;
int b;
void showa()
{
std::cout<<"a="<<a<<endl;
}
void showb()
{
std::cout<<"b="<<b<<endl;
}
};
void (TEST::*pshow)();
int main()
{
TEST t(100,200);
TEST t2(1000,2000);
int TEST::*pa = &TEST::a;
std::cout<<"ap="<<t.*pa<<endl;
pshow = &TEST::showa;
(t.*pshow)();
(t2.*pshow)();
pshow = &TEST::showb;
(t.*pshow)();
(t2.*pshow)();
return 0;
}
更多推荐

所有评论(0)