版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
#include <map>
#include <vector>
typedef double (*MyCalFun_ptr)(const std::vector<int> &);
std::map<std::string,MyCalFun_ptr> func_list; //存放自定义的函数名,及其功能实现函数
double mymax(const std::vector<int> &token_list)
{
std::size_type token_size = token_list.size();
maxnum = token_list[0];
for(std::size_type i = 0 ; i < token_size ; ++i)
{
if(token_list[i] > max)
{
max = token_list[i]
}
}
return max;
}
std::map<std::string,MyCalFun_ptr> func_list {{"MAX",mymax}}