C++ visual studio 2010 express STL列表编译器错误
我正在将一些代码从linux移植到windows,并且出现了一些奇怪的错误。我有以下课程: (标题)C++ visual studio 2010 express STL列表编译器错误,c++,visual-studio-2010,stl,C++,Visual Studio 2010,Stl,我正在将一些代码从linux移植到windows,并且出现了一些奇怪的错误。我有以下课程: (标题) 区域矩形 #ifndef __RECTANGLE_H__ #define __RECTANGLE_H__ #include <iostream> using namespace std; class Rectangle { public: Rectangle(int x = 0,int y = 0,int width = 0,int height = 0, int thres
区域矩形
#ifndef __RECTANGLE_H__
#define __RECTANGLE_H__
#include <iostream>
using namespace std;
class Rectangle
{
public:
Rectangle(int x = 0,int y = 0,int width = 0,int height = 0, int threshold=0);
int x();
int y();
int width();
int height();
void x(int);
void y(int);
void width(int);
void height(int);
void threshold(int);
int threshold(void);
friend ostream& operator<<(ostream& output, const Rectangle& r);
private:
int _x;
int _y;
int _width;
int _height;
int _threshold;
};
#endif
第三个引用文件确实包含RegionRectangle.h。您知道为什么这样做不起作用吗
1> Utils.cpp
1>c:\documents and settings\ferru001\my documents\work\cira_svn\win32_cira\Utils.h(56): error C2923: 'std::list' : 'Rectangle' is not a valid template type argument for parameter '_Ty'
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(3989) : see declaration of 'Rectangle'
1>c:\documents and settings\ferru001\my documents\work\cira_svn\win32_cira\Utils.h(60): error C2923: 'std::list' : 'Rectangle' is not a valid template type argument for parameter '_Ty'
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(3989) : see declaration of 'Rectangle'
1> Utils.cpp
1> c:\documents and settings\ferru001\my documents\work\cira\u svn\win32\u cira\Utils.h(56):错误C2923:'std::list':'Rectangle'不是参数'\u Ty'的有效模板类型参数
1> C:\Program Files\Microsoft SDK\Windows\v7.0A\include\wingdi.h(3989):请参见“矩形”的声明
1> c:\documents and settings\ferru001\my documents\work\cira\u svn\win32\u cira\Utils.h(60):错误C2923:'std::list':'Rectangle'不是参数'\u Ty'的有效模板类型参数
1> C:\Program Files\Microsoft SDK\Windows\v7.0A\include\wingdi.h(3989):请参见“矩形”的声明
关键是:
C:\Program Files\Microsoft SDK\Windows\v7.0A\include\wingdi.h(3989)
:参见“矩形”的声明
编译器认为您指的是wingdi.h中的Win32 SDK矩形函数,而不是刚才定义的函数。我建议重命名您的矩形(或输入名称空间),看看会发生什么。请正确格式化您的代码,而不要尝试使用HTML标记(在这里不起作用)。具体来说,使用工具栏上的“0101”按钮将代码标记为代码,不要将
引用为
和
。还有什么是编译器错误?1>Utils.cpp 1>c:\documents and settings\ferru001\my documents\work\cira\u svn\win32\u cira\Utils.h(56):错误C2923:'std::list':'Rectangle'不是参数'\u Ty'1>C:\Program Files\Microsoft SDK\Windows\v7.0A\include\wingdi.h(3989)的有效模板类型参数:请参阅'Rectangle'1>C:\documents and settings\ferru001\my documents\work\cira\u svn\win32\cira\Utils.h(60)的声明:错误C2923:'std::list':'Rectangle'不是参数'\u Ty'的有效模板类型参数。您可以编辑问题以包含该文本供参考。非常感谢,我显然没有仔细查看错误消息。。。工作了12个小时:)非常感谢你的帮助
bool hasKey( map<PageNumberSide, list<Rectangle> > myMap, PageNumberSide myKey);
enter code here
1> Utils.cpp
1>c:\documents and settings\ferru001\my documents\work\cira_svn\win32_cira\Utils.h(56): error C2923: 'std::list' : 'Rectangle' is not a valid template type argument for parameter '_Ty'
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(3989) : see declaration of 'Rectangle'
1>c:\documents and settings\ferru001\my documents\work\cira_svn\win32_cira\Utils.h(60): error C2923: 'std::list' : 'Rectangle' is not a valid template type argument for parameter '_Ty'
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(3989) : see declaration of 'Rectangle'