• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >vc/mfc > map中find方法的问题

map中find方法的问题

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-06-04

佚名通过本文主要向大家介绍了map find,c map find,std map find,map的find用法,stl map find等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: map中find方法的问题
描述:

使用map中的find()方法  VC6中
编译提示出错:
--------------------Configuration: AutoParticiple - Win32 Debug--------------------
Compiling...
Dictionary.cpp
F:\Project\Visual C++\AutoParticiple\Dictionary.cpp(30) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::_Tree<int,struct std::pair<int const ,int>,struct std::map<int,int,struct std::less<int>,cla
ss std::allocator<int> >::_Kfn,struct std::less<int>,class std::allocator<int> >::const_iterator' (or there is no acceptable conversion)
F:\Project\Visual C++\AutoParticiple\Dictionary.cpp(31) : error C2679: binary '!=' : no operator defined which takes a right-hand operand of type 'class std::_Tree<int,struct std::pair<int const ,int>,struct std::map<int,int,struct std::less<int>,cl
ass std::allocator<int> >::_Kfn,struct std::less<int>,class std::allocator<int> >::const_iterator' (or there is no acceptable conversion)
Error executing cl.exe.
AutoParticiple.exe - 2 error(s), 0 warning(s)
源码如下
Dictionary.h
#ifndef _Dictionary_H_
#define _Dictionary_H_
#pragma warning(disable: 4786)
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std; 
const string DICTIONARYNAME("words.dictionary");
class Dictionary {
public:
Dictionary(); 
~Dictionary(); 
bool IsWord(string&) const; 
int getIndex(string&) const;
int getFrequency(int) const;
private:
map<string, int> wordDictionary;
map<int, int> frequencyDictionary;
void OpenDictionary();
};
#endif
Dictioanry.cpp
#include "Dictionary.h"
Dictionary::Dictionary() 
{
OpenDictionary();
}
Dictionary::~Dictionary() 
{
wordDictionary.clear();
frequencyDictionary.clear();
}
/* Esitimate whether a word in word dictionary. */
bool Dictionary::IsWord(string& word) const
{
if(wordDictionary.find(word) != wordDictionary.end())
return true;
return false;
}
int Dictionary::getFrequency(int id) const
{
map<int, int>::iterator position;
position =  frequencyDictionary.find(id);
if(position != frequencyDictionary.end())
return (*position).second;
else
return -1;
}
void Dictionary::OpenDictionary()
{
FILE *fpDictionary;
if((fpDictionary = fopen(DICTIONARYNAME.c_str(), "r")) == NULL) {
cout << "Cannot open the Dictionary file!";
exit(1);
}
int id, frequency;
char word[16];
while(fscanf(fpDictionary, "%d %s %d", &id, word, &frequency) != EOF) {
wordDictionary.insert(pair<string, int>(word, id));
frequencyDictionary.insert(pair<int, int>(id, frequency));
}
fclose(fpDictionary);
}
如何解决?


分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • map中find方法的问题

相关文章

  • 2017-06-04 请问mfc单文档应用动态添加active控件,如何响应控件自定义事件
  • 2017-06-04 AutoCADobjectarx启动可执行程序
  • 2017-06-05 dll显式调用出错,隐式没有问题,什么原因?;在线等,解决立即给分!
  • 2017-06-05 Shell扩展问题,如何拦截文件夹的双击操作
  • 2017-06-04 COM理论问题(查询不同接口,欢迎高手),希望得到您点睛之语。参与有分,up有分。
  • 2017-06-05 调用LoadLibrary时,无法访问是什么原因?
  • 2017-06-04 CPaneDialog最小长宽问题
  • 2017-06-05 大家好,如何用VC做一个软件监测另个一个软件发送出来的指令,和接收到的指令
  • 2017-06-04 可不可以在activex中画控件,就是在控件中用控件
  • 2017-06-05 VC串口通信问题

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • mfc开发WindowsMediaPlayer播放列表如何与列表框实时同步,显示正在播放,请大神赐教!
    • 100分放送!请教有关atl入门资料!
    • 请问有没有检测程序是否缺少dll的工具?我的程序在98下不好用,2000,xp下正常
    • 很菜的调用DLL的问题,不过要知道!·
    • 特别着急!如何对netmeeting进行二次开发??
    • 昨天子线程还能调用,今天程序代码都没动怎么就不行了
    • 开发asp方面的组件,需要注意那些问题
    • 高手:VB从VCCom中取二进制数据,在ATL中怎样定义,怎样赋值出去。谢谢!
    • Combobox的Activex实现
    • 弱弱的问题,有关于组件插件开发层面上的的区别?

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有