问题描述
我正在使用turbo c complier获取给定代码: -
i am using turbo c complier for the given code :-
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
class hexa
{
private:
int x,y,pts[12][12],s;
float h,r;
public:
void set(){
cout<<"enter the cordinates";
cin>>x>>y;
cout<<"enter the length of hexagonal";
cin>>s;
}
void disp(){
cout<<x<<y;
cout<<s;
}
void Draw()
{
h = 0.5* s;
r = 0.866*s;
pts[0][0] =x; pts[0][1] =y;
pts[1][0] =x+h; pts[1][1] = y+r;
pts[2][0] =x; pts[2][1] = y+r;
pts[3][0] =x-h; pts[3][1] =y+r;
pts[4][0] =x; pts[4][1] =y-r;
pts[5][0] =x-h; pts[5][1] =y-r;
pts[6][0] =x+h; pts[6][1] =y-r;
drawpoly(7,pts[0][0],pts[0][1],pts[1][0],pts[1][1],pts[2][0],pts[2][1],pts[3][0],pts[3][1],pts[4][0],pts[4][1],pts[5][0],pts[5][1],pts[6][0],pts[6][1],pts[0][0],pts[0][1]);
}
};
main()
{
hexa c;
int gd=DETECT,gm;
initgraph(&gd, &gm, "C:\\TurboC3\\BGI");
c.set();
c.disp();
c.Draw();
getch();
closegraph();
return 0;
}
它会出现以下错误: -
1)无法将int转换为const int远*
2)类型不匹配参数_polypoints调用drawpoly(int,const int far)
3)额外参数in调用drawpoly(int,const int far)
无法恢复错误plz帮助我..我会谢谢你。
and it gives the following errors :-
1)cannot convert int to const int far*
2)type mismatch parameter _polypoints to call a drawpoly(int,const int far)
3)extra parameter in call to drawpoly(int,const int far)
am not able to recover errors plz help me .. i''ll be thankfull to uh.
推荐答案
drawpoly(7,pts[0][0],pts[0][1],pts[1][0],pts[1][1],pts[2][0],pts[2][1],pts[3][0],pts[3][1],pts[4][0],pts[4][1],pts[5][0],pts[5][1],pts[6][0],pts[6][1],pts[0][0],pts[0][1]);
我认为你应该这样做;
I think you should do;
drawpoly(7, pts);
因为函数需要一个项目计数和指向它们的指针,而不是每个项目单独。
希望这会有所帮助,
Fredrik
as the function expects a count of items and a pointer to them, not each item individually.
Hope this helps,
Fredrik
这篇关于错误错误错误!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!