2010-09-01 2 views
2

Я переношу некоторый код из linux в windows и придумываю какую-то странную ошибку. У меня есть следующий класс:visual studio 2010 express STL list compiler error

(заголовок)
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&lt;&lt;(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' 
+1

Пожалуйста, отформатируйте свой код правильно, вместо того, чтобы пытаться использовать разметку HTML (которая здесь не работает). В частности, используйте кнопку «0101» на панели инструментов, чтобы пометить код как код, и сделайте _not_ quote '<' and '>' как '<' и '>'. –

+0

также какова ошибка компилятора? –

+0

1> Utils.cpp 1> c: \ документы и настройки \ ferru001 \ мои документы \ work \ cira_svn \ win32_cira \ Utils.h (56): ошибка C2923: 'std :: list': 'Rectangle' не является допустимый аргумент типа шаблона для параметра «_Ty» 1> C: \ Program Files \ Microsoft SDK \ Windows \ v7.0A \ include \ wingdi.h (3989): см. объявление «Прямоугольник» 1> c: \ документы и Настройки \ ferru001 \ мои документы \ work \ cira_svn \ win32_cira \ Utils.h (60): ошибка C2923: 'std :: list': 'Rectangle' не является допустимым аргументом типа шаблона для параметра '_Ty' –

ответ

3

Ключ:

C: \ Program Files \ Microsoft SDKs \ Windows \ v7.0A \ включать \ wingdi.h (3989) : см декларацию 'Прямоугольник'

Компилятор считает, что вы имеете в виду функцию Rectangle Win32 SDK в wingdi.h, а не тот, который вы только что определили. Я предлагаю переименовать ваш прямоугольник (или помещать пространство имен) и посмотреть, что произойдет.

+0

Большое спасибо, я, очевидно, недостаточно внимательно посмотрел на сообщения об ошибках ... работал на 12 часов :) Большое спасибо за вашу помощь –

Смежные вопросы