||
perl中有getopt::long 模块
c++中有program_options模块,
-------------------
安装也挺简单的,见
www_3fwork_com_b201_001786MYM014322.pdf
只需添加2个路径
这样就可以使用boost了。
-------------------------------------------------------------------
ref:
http://huangws138.blog.163.com/blog/static/587906212011112111913796/
c++ map count、find
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;
void main()
{
//定义map 对象
map<string,int> word;
//定义指针
map<string,int>::iterator it;
//向word 插入元素 ("a",9)
word.insert (map<string,int>::value_type("a",9));
//查找 键是"a"的元素,返回指向元素的指针。
it=word.find ("a");
//如果元素不存在,指针指向word.end().
if(it!=word.end ())
cout<<it->second<<endl; //输出元素的值
//查找 键是"a"的元素,
int result=word.count ("a");
//如果键存在返回1,否则返回0
if(result)
cout<<word["a"]<<endl; //输出元素的值
cout<<endl;
}
------------------------------------------------------------------------------------
variables_map vm;// variables_map 是map的一种。
map 可以只有键,没有值。
--------------------------------------------------
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-10-20 02:02
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社