fillpolygon(poly1, 4);报错:int*与const point*不符
时间: 2023-08-28 12:30:31 浏览: 50
这个报错是因为 `fillpolygon` 函数的参数类型应该是 `const point*`,而你传入的是 `int*`,类型不匹配。
解决这个问题的方法有两种:
1. 将 `poly1` 数组转换成 `POINT` 结构体数组,然后传入 `fillpolygon` 函数。
```
POINT poly1Points[] = { { 100, 150 }, { 200, 50 }, { 300, 150 }, { 200, 250 } };
fillpolygon(poly1Points, 4);
```
2. 将 `fillpolygon` 函数封装成一个接受 `int*` 类型参数的函数。
```
void fillpolygon_int(int* points, int count) {
POINT* polyPoints = new POINT[count];
for (int i = 0; i < count; i++) {
polyPoints[i].x = points[2 * i];
polyPoints[i].y = points[2 * i + 1];
}
fillpolygon(polyPoints, count);
delete[] polyPoints;
}
```
这个函数将 `int*` 类型的点数组转换成 `POINT` 结构体数组,然后调用 `fillpolygon` 函数。你可以使用这个函数来绘制多边形。
```
int poly1[] = { 100, 150, 200, 50, 300, 150, 200, 250 };
fillpolygon_int(poly1, 4);
```
这两种方法都可以解决 `int*` 与 `const point*` 不匹配的问题。