Vector<class>

I want to print the contents of allPolygons vector, I don't know how to do this.
The code in not mine but I trying to understand the code to do other things. I bolded the items of interest

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

int numShapeEdges(oaDesign *view, oaLayerNum layerNum, oaPurposeNum purpNum, vector<oaPointArray> &allPolygons){
oaIter<oaLPPHeader> headers(view->getTopBlock()->getLPPHeaders());
int countShapeEdges = 0;
while (oaLPPHeader *lppHeader = headers.getNext()) {
 oaLayerNum lppLayerNum = lppHeader->getLayerNum();
 oaPurposeNum lppPurpNum = lppHeader->getPurposeNum();
 if (lppLayerNum == layerNum){
  if (!lppHeader->getShapes().isEmpty()) {
   oaIter<oaShape> shapes(lppHeader->getShapes());
   while (oaShape *shape = shapes.getNext()){
    oaType type = shape->getType();
    oaPolygon *poly;
    if (type.getName() == "Polygon"){
     poly = static_cast<oaPolygon*>(shape);
    }
    else if (type.getName() == "Rect") {
     oaRect *rect = static_cast<oaRect*>(shape);
     poly = rect->convertToPolygon();
    }
    oaPointArray points; //Declaration
        poly->getPoints(points);
    allPolygons.push_back(points);
        cout << "Vector Contain the following points: ";
        for(std::vector<oaPointArray>::iterator it = allPolygons.begin() ; it != allPolygons.end(); ++it)
        {
           cout << ' ' <<&it;
        }
        cout << '\n';
       
    countShapeEdges += points.getNumElements();
       
   }
   }
 }
}
return countShapeEdges;
}
cout << ' ' <<&it; should be cout << ' ' << *it; (presuming that oaPointArray has overloaded operator<<)

I suggest to upgrade to compiler which supports C++11 and just write:
1
2
for(const auto& x: allPolygons)
    std::cout << ' ' << x;
Topic archived. No new replies allowed.