佚名通过本文主要向大家介绍了java中map的用法,map的用法,js中map的用法,java map用法,c map用法等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 60分求map的用法!
描述:
解决方案1:
描述:
大家谁用过map?可以帮俺一下吗?
俺的QQ:35547527,谢谢!
解决方案1:
for(map<int,CStudent*>::iterator itr = pStudent.begin; itr != pStudent.end; itr++)
{
int nCode = itr->first;
theStudentList.push_back(nCode);
}
map是由树来实现的,只能通过键(并且唯一)找到值,比如map<int,CStudentInfo*>中你只能通过一个int数据得到一个CStudentInfo*,不能再帮你查询其他的了.另外map<int,CStudent*>::iterator 是指向pair<int,CStudent*>的,因此itr->first就是那个int, itr->second就是CStudent*
解决方案3:就像交警的警号和人名一样,一对一