我正在將一些代碼從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