map1.cpp

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #ifdef __BCPLUSPLUS__
#include <map.h>
#else
#include <map>
#endif

#include <iostream.h>
#include <string.h>

using namespace std;
class ltstr
 {
  public:
    bool operator()(const char* s1, const char* s2) const
     { return (strcmp(s1, s2) < 0);}
 };

void main(void)
{
  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;
}

'void __thiscall CMap1View::OnRGBSplit(void)' : overloaded function differs only by return type from 'int __thiscall CMap1View::OnRGBSplit(void)' d:\vc6.0\microsoft visual studio\myprojects\map1\map1view.h(22) : see declaration of 'OnRGBSplit' D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(110) : error C2371: 'OnRGBSplit' : redefinition; different basic types d:\vc6.0\microsoft visual studio\myprojects\map1\map1view.h(22) : see declaration of 'OnRGBSplit' D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(111) : error C2065: 'm_image' : undeclared identifier D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(111) : error C2228: left of '.empty' must have class/struct/union type D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(112) : error C2143: syntax error : missing ')' before '{' D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(118) : error C2065: 'vector' : undeclared identifier D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(118) : error C2065: 'Mat' : undeclared identifier D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(118) : error C2065: 'channels' : undeclared identifier D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(118) : warning C4804: '>' : unsafe use of type 'bool' in operation D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(118) : warning C4552: '>' : operator has no effect; expected operator with side-effect D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(119) : error C2065: 'split' : undeclared identifier D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(121) : error C2001: newline in constant D:\VC6.0\Microsoft Visual Studio\MyProjects\map1\map1View.cpp(121) : fatal error C1057: unexpected end of file in macro expansion
最新发布
10-15
要解决VC6.0中CMap1View类OnRGBSplit函数重定义及多个标识符未声明等编译错误,可参考以下方法: ### 解决OnRGBSplit函数重定义问题 函数重定义通常意味着在代码里对同一个函数进行了多次定义。需要检查代码文件,保证OnRGBSplit函数只定义一次。一般而言,函数声明会放在头文件(.h)中,而函数定义会放在源文件(.cpp)中。例如,在CMap1View.h文件中进行函数声明: ```cpp // CMap1View.h class CMap1View : public CView { // ... afx_msg void OnRGBSplit(); // ... }; ``` 在CMap1View.cpp文件中进行函数定义: ```cpp // CMap1View.cpp #include "CMap1View.h" void CMap1View::OnRGBSplit() { // 函数实现代码 } ``` ### 解决m_image未声明问题 m_image未声明表明编译器没有找到该变量的定义。要确保在使用m_image之前,已经对其进行了声明。可在CMap1View类的头文件中声明该变量: ```cpp // CMap1View.h class CMap1View : public CView { // ... CImage m_image; // 假设m_image是CImage类型 // ... }; ``` 同时,要保证包含了m_image所属类型的头文件,例如: ```cpp #include <atlimage.h> // 包含CImage所需的头文件 ``` ### 解决语法错误 语法错误一般是由代码书写不规范造成的,像括号不匹配、分号缺失等。仔细检查出错的代码行,查看是否存在拼写错误、语法格式不正确等问题。例如,确保每个语句都以分号结尾,函数调用的参数数量和类型与声明一致。 ### 解决vector和Mat等标识符未声明问题 标识符未声明通常是因为没有包含相应的头文件。 - **vector**:vector是STL(标准模板库)中的容器,要包含`<vector>`头文件: ```cpp #include <vector> using std::vector; ``` - **Mat**:Mat是OpenCV库中的矩阵类型,需要包含OpenCV的头文件,并且要配置好OpenCV的库路径和链接库: ```cpp #include <opencv2/opencv.hpp> using namespace cv; ``` 另外,由于MFC出现时STL还未成为C++标准,MFC有自己的模板库,若在VC6编译器适用的模板语法在VC9不适用,特别是当四个环境变量设置不兼容时会出现编译错误,所以也要检查环境变量的设置是否正确[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值