开发者

visual studio 2010 express STL list compiler error

开发者 https://www.devze.com 2023-01-13 21:50 出处:网络
I am porting some code from linux to windows and am coming up with some strange error.I have the following class:

I am porting some code from linux to windows and am coming up with some strange error. I have the following class:

(header)

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)开发者_如何学C;
    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

(implementation)

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&lt;&lt;(ostream& output, const Rectangle& p)
{
    output << "[ (" << p._x << "," << p._y << "," << p._width << "," << p._height << "), threshold: " << p._threshold << " ]";
    return output;
}

I have another header file that has a function as such:

bool hasKey( map<PageNumberSide, list<Rectangle> > myMap, PageNumberSide myKey);

The error messages I'm getting are these:

enter code here

This third referencing file does include RegionRectangle.h any ideas why this would not work?

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'


The key is:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(3989) : see declaration of 'Rectangle'

The compiler thinks you're referring to the Win32 SDK Rectangle function in wingdi.h, not the one you just defined. I suggest renaming your rectangle (or putting in a namespace) and seeing what happens.

0

精彩评论

暂无评论...
验证码 换一张
取 消