麻烦大家帮忙看看这个C++程序#include #include #include #include "rect.h"#
麻烦大家帮忙看看这个C++程序
#include
#include
#include
#include "rect.h"
#include "ezwin.h"
using namespace std;
int ApiMain() {
enum color {Red,Green,Blue,Yellow,Cyan,Magenta};
SimpleWindow W("Builings",10,10);
ifstream fin("data.txt");
float Width=0;
float High=0;
float XCentre=0;
float YCentre=0;
color Color=Red;
W.Open();
RectangleShape Build1(W,fin>>XCentre,fin>>YCentre,Red,fin>>Width,fin>>High);
RectangleShape Build2(W,fin>>XCentre,fin>>YCentre,Green,fin>>Width,fin>>High);
RectangleShape Build3(W,fin>>XCentre,fin>>YCentre,Blue,fin>>Width,fin>>High);
RectangleShape Build4(W,fin>>XCentre,fin>>YCentre,Magenta,fin>>Width,fin>>High);
RectangleShape Build5(W,fin>>XCentre,fin>>YCentre,Yellow,fin>>Width,fin>>High);
Build1.Draw();
Build2.Draw();
Build3.Draw();
Build4.Draw();
Build5.Draw();
return 0;
}
编译出错,系统提示:
--------------------Configuration:p337 - Win32 Debug--------------------
Compiling...
p337.cpp
C:Program FilesMicrosoft Visual StudioMyProjectsp337p337.cpp(17) :error C2664:'__thiscall RectangleShape::RectangleShape(class SimpleWindow &,float,float,const enum color &,float,float)' :cannot convert parameter 2 from 'class std::basic_ist
ream' to 'float'
No user-defined-conversion operator available that can perform this conversion,or the operator cannot be called
C:Program FilesMicrosoft Visual StudioMyProjectsp337p337.cpp(18) :error C2664:'__thiscall RectangleShape::RectangleShape(class SimpleWindow &,float,float,const enum color &,float,float)' :cannot convert parameter 2 from 'class std::basic_ist
ream' to 'float'
No user-defined-conversion operator available that can perform this conversion,or the operator cannot be called
C:Program FilesMicrosoft Visual StudioMyProjectsp337p337.cpp(19) :error C2664:'__thiscall RectangleShape::RectangleShape(class SimpleWindow &,float,float,const enum color &,float,float)' :cannot convert parameter 2 from 'class std::basic_ist
ream' to 'float'
No user-defined-conversion operator available that can perform this conversion,or the operator cannot be called
C:Program FilesMicrosoft Visual StudioMyProjectsp337p337.cpp(20) :error C2664:'__thiscall RectangleShape::RectangleShape(class SimpleWindow &,float,float,const enum color &,float,float)' :cannot convert parameter 2 from 'class std::basic_ist
ream' to 'float'
No user-defined-conversion operator available that can perform this conversion,or the operator cannot be called
请问是什么问题该怎么解决?
还有一个问题是:枚举类型的数据要想从文件直接输入到变量应该用什么语句?(直接用fin>>Color,Color是枚举类型,不能编译)