【发布时间】:2010-09-01 22:26:36
【问题描述】:
我正在将一些代码从 linux 移植到 windows 并出现一些奇怪的错误。我有以下课程:
(标题)
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> 实用程序.cpp 1>c:\documents and settings\ferru001\my documents\work\cira_svn\win32_cira\Utils.h(56): error C2923: 'std::list' : 'Rectangle' 不是参数 ' 的有效模板类型参数_Ty' 1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(3989):见“矩形”的声明 1>c:\documents and settings\ferru001\my documents\work\cira_svn\win32_cira\Utils.h(60): error C2923: 'std::list' : 'Rectangle' 不是参数 ' 的有效模板类型参数_Ty' 1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(3989):见“矩形”的声明【问题讨论】:
-
请正确格式化您的代码,而不是尝试使用 HTML 标记(这在此处不起作用)。具体来说,使用工具栏上的“0101”按钮将代码标记为代码,并且不将
&lt;和&gt;引用为&lt;和&gt;。 -
还有什么是编译器错误?
-
1> Utils.cpp 1>c:\documents and settings\ferru001\my documents\work\cira_svn\win32_cira\Utils.h(56): error C2923: 'std::list' : 'Rectangle' 不是参数'_Ty' 1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(3989) 的有效模板类型参数:请参阅'Rectangle' 1>c 的声明:\documents and settings\ferru001\my documents\work\cira_svn\win32_cira\Utils.h(60): error C2923: 'std::list' : 'Rectangle' 不是参数'_Ty'的有效模板类型参数
-
您可以编辑您的问题以包含该文本以供参考。
标签: c++ visual-studio-2010 stl