C++ Notes --- Function Pointers

在多链的源码中,多次出现函数指针的身影:

1
2
3
4
5
6
7
8
9
10
11
12
typedef json_spirit::Value(*rpcfn_type)(const json_spirit::Array& params, bool fHelp);

class CRPCCommand
{
public:
std::string category;
std::string name;
rpcfn_type actor;
bool okSafeMode;
bool threadSafe;
bool reqWallet;
};

阅读的难点在于,源码中的 json_spirit::Value(*rpcfn_type)(const json_spirit::Array& params, bool fHelp) 中间没有空格。

调用函数指针,获取结果:

1
json_spirit::Value result = pcmd->actor(params, false);
配置网络文件共享 Shellchain笔记:序列化与反序列化

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×