我正在将一些代码从linux移植到windows,并且出现了一些奇怪的错误。我有以下类:visual studio 2010 express STL列表编译器错误
(头)
RegionRectangle.h
#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.cpp
#include "RegionRectangle.h"
Rectangle::Rectangle(int myx,int myy, int mywidth, int myheight,int threshold)
{
_x=myx;
_y=myy;
_width=mywidth;
_height=myheight;
_threshold=threshold;
}
int Rectangle::x(void)
{
return _x;
}
int Rectangle::y(void)
{
return _y;
}
int Rectangle::width(void)
{
return _width;
}
int Rectangle::height(void)
{
return _height;
}
void Rectangle::x(int x)
{
_x=x;
}
void Rectangle::y(int y)
{
_y=y;
}
void Rectangle::width(int width)
{
_width=width;
}
void Rectangle::height(int height)
{
_height=height;
}
void Rectangle::threshold(int thresh)
{
_threshold=thresh;
}
int Rectangle::threshold(void)
{
return _threshold;
}
ostream& operator<<(ostream& output, const Rectangle& p)
{
output << "[ (" << p._x << "," << p._y << "," << p._width << "," << p._height << "), threshold: " << p._threshold << " ]";
return output;
}
我有了另一头文件功能如下:
bool hasKey(map<PageNumberSide, list<Rectangle> > myMap, PageNumberSide myKey);
条
我收到错误消息是这些:
enter code here
这第三个引用文件不包含任何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'
请正确格式化您的代码,而不是尝试使用HTML标记(这在此不起作用)。具体来说,使用工具栏上的“0101”按钮将代码标记为代码,并且不要将'<' and '>'标记为'<'和'>'。 – 2010-09-01 22:28:54
还有什么编译器错误? – 2010-09-01 22:30:05
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参数'_Ty'的有效模板类型参数1> C:\ Program Files \ Microsoft SDKs \ Windows \ v7.0A \ include \ wingdi.h(3989):参见'Rectangle'声明 1> c:\ documents和设置\ ferru001 \ my documents \ work \ cira_svn \ win32_cira \ Utils.h(60):错误C2923:'std :: list':'Rectangle'不是参数'_Ty'的有效模板类型参数 – 2010-09-01 22:34:14