vc中不支持map头文件吗?

cjxiaoh 2002-09-04 04:00:45
vc中有没有map.h头文件呢?如果没有拿什么替代阿。
...全文
503 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zheng_can 2002-09-05
  • 打赏
  • 举报
回复
要 #include <map>
using std::map;

不要 #include <map.h>
dajian2000 2002-09-04
  • 打赏
  • 举报
回复
include 文件夹中没有map.h 只有 map

cjxiaoh 2002-09-04
  • 打赏
  • 举报
回复
我在程序中包含了这样的头文件就出错了
#include <map.h>
#include <iostream.h>
#include <string.h>
提示找不到map.h的路径。
fangrk 2002-09-04
  • 打赏
  • 举报
回复
#include <map>
#include <iostream>
using namespace std;
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
int main()
{
map<const char*, int, ltstr> months;

months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;

cout << "june -> " << months["june"] << endl;
map<const char*, int, ltstr>::iterator cur = months.find("june");
map<const char*, int, ltstr>::iterator prev = cur;
map<const char*, int, ltstr>::iterator next = cur;
++next;
--prev;
cout << "Previous (in alphabetical order) is " << (*prev).first << endl;
cout << "Next (in alphabetical order) is " << (*next).first << endl;
}
tinytot 2002-09-04
  • 打赏
  • 举报
回复
#include <map>

70,022

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧