#Cpp

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

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);
Your browser is out-of-date!

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

×