STL之set/multiset(二)
来源:互联网 发布:lambda表达式java 编辑:程序博客网 时间:2024/06/06 00:52
---------------------------------------------------- find(key)查找函数之自定义的数据类型 ----------------------------------------------------#include <iostream>#include <set>#include <string>#include <stdlib.h>using namespace std;class Student{public: Student(string name,int age) { this->m_name = name; this->m_age = age; } Student(){} ~Student(){}public: bool operator<(const Student& s) const { return this->m_age < s.m_age; }public: string m_name; int m_age;};void test00(){ set<Student> s; s.insert(Student("aaa",22)); s.insert(Student("bbb",23)); s.insert(Student("ccc",24)); s.insert(Student("ddd",25)); set<Student>::iterator it = s.find(Student("ccc",24)); if (it == s.end()) { cout<<"查找失败!"<<endl; } else { cout<<"查找成功!"<<endl; cout<<it->m_name<<" "<<it->m_age<<endl; }}int main(){ test00(); system("pause"); return 0;}结果:查找成功!ccc 24
阅读全文
0 0
- STL之set/multiset(二)
- STL学习之路二(set与multiset)
- STL之二:set/multiset用法详解
- STL之set&multiset容器(笔记)
- (STL之set与multiset)SPOJ
- stl库之set、multiset
- STL之set和multiset
- STL容器之Set,MultiSet
- STL容器之set/multiset
- STL之set/multiset容器
- STL之set和multiset
- STL 之set和multiset(江南烟雨)
- STL 之 初识set multiset(map multimap)
- STL之Set与Multiset(转)
- STL之五:set/multiset用法详解
- STL之五:set/multiset用法详解
- STL之五:set/multiset用法详解
- STL之set和multiset详解
- 数据可视化四:Matlab数据可视化(三)
- Keyboard Row
- html文本链接
- MySQL两表关联的连接表该如何创建索引?
- C++作业六
- STL之set/multiset(二)
- redis
- 玲珑杯Round #14 B题 RE:从零开始的异世界生活(离线+线段树)
- struts2
- 2017年5月14日23:30:35 367. Valid Perfect Square
- win7下安装Ubuntu16.04及android源码下载,编译
- 面向开发的测试技术(三):Web自动化测试
- mysql配置及授权
- 如何解决jdbc中出现的java.io.NotSerializableException