返回信息流struct card_inserted
{
std::string account;
};
class atm
{
messaging::receiver incoming;
messaging::sender bank;
messaging::sender interface_hardware;
void (atm::*state)();
std::string account;
std::string pin;
void waiting_for_card() // 1
{
interface_hardware.send(display_enter_card()); // 2
incoming.wait(). // 3
handle<card_inserted>(
[&](card_inserted const& msg) // 4
{
account=msg.account;
pin="";
interface_hardware.send(display_enter_pin());
state=&atm::getting_pin;
}
);
}
void getting_pin();
public:
void run() // 5
{
state=&atm::waiting_for_card; // 6
try
{
for(;;)
{
(this->*state)(); // 7
}
}
catch(messaging::close_queue const&)
{
}
}
};
如上述代码中,void (atm::*state)();这个成员函数是什么意思?这是种神马写法呢。。
这是一条镜像帖。来源:北邮人论坛 / cpp / #95126同步于 2017/4/17
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
帮忙看下这个成员函数是什么意思?
gankthisway
2017/4/17镜像同步4 回复
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
虽然我也不懂函数指针,不过我还是去google了一下看了看。http://www.cnblogs.com/windlaughing/archive/2013/04/10/3012012.html 也许LZ就看懂了。