#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}}
map存放函数指针
最新推荐文章于 2023-03-30 22:48:52 发布