Hello,

Why I get this confusing error

:
VVc_demo.cpp: In function `bool read_polygons(const char*, Polygons_list_2&,
Bbox_2&)':
VVc_demo.cpp:617: error: conflicting types for `read_polygons(const char*,
Polygons_list_2&, Bbox_2&)::domain ifile'
VVc_demo.cpp:598: error: previous declaration as `std::ifstream ifile'
VVc_demo.cpp:617: error: syntax error before `>>' token
VVc_demo.cpp:629: error: no match for 'operator>>' in 'ifile >> n_vertices'
the function that has problem is:
bool read_polygons (const char *filename, Polygons_list_2& polygons, Bbox_2& bbox)
{
// Open the input file.
std::ifstream ifile (filename);
std::ofstream ofile ("domain.txt", 'w'); if (! ifile.is_open()) {
std::cerr << "Failed to open <" << filename << ">." << std::endl;
return (false);
}
// Read the number of input polygons.
int n_polygons;
struct domain {
float xMin;
float xMax;
float yMin;
float yMax;
}
ifile >> n_polygons; // Read the polygons.
int n_vertices;
Rational x, y;
std::list<Rat_point_2> vertices;
int i, j;
bool domainFlag = true; // for extracting domain min max points. first usage is true
for (i = 0; i < n_polygons; i++) {
// Read the number of vertices in the current polygon.
ifile >> n_vertices; // Read the vertices.
vertices.clear();
for (j = 0; j < n_vertices; j++) {
ifile >> x >> y;
vertices.push_back (Rat_point_2 (x, y));
}
// Create a polygon and append it to the output list.
Rat_polygon_2 pgn (vertices.begin(), vertices.end());
if (! pgn.is_simple()) {
std::cerr << "Error - Polygon no. " << i + 1 << " is not simple." << std::endl;
return (false);
}
// for first polygon (domain) we have to extract boundary point
// so that generated random milestones have to fit in domain
if ( domainFlag ) {
domain.xMin = pgn.left_vertex_2();
domain.xMax = pgn.right_vertex_2();
domain.yMin = pgn.bottom_vertex_2();
domain.yMax = pgn.top_vertex_2();
if (ofile.is_open()) {
ofile << domain.xMin << domain.xMax
<< domain.yMin << domain.yMax;
}
ofile.close();
domainFlag = false; // for other polygons, we do not need it
}
polygons.push_back (pgn);
// Update the bounding box.
if (i == 0)
bbox = pgn.bbox();
else
bbox = bbox + pgn.bbox();
}
// Successful termination.
ifile.close();
return (true);
}