|
Not pointers in general, just specifically the "this" pointer. Like in a graph class, when comparing if two nodes are both the in the graph you called them with.
template <typename NodeInfo, typename ArcInfo>
bool Graph<NodeInfo, ArcInfo>::AreConnected(Node *n1, Node *n2)
{
Iterator<Arc *> *iterator;
bool found;
if (n1->graph != this || n2->graph != this) {
Error("AreConnected: Nodes are in different graphs");
}
iterator = arcs->CreateIterator();
found = false;
while (!found && iterator->HasNext()) {
Arc *arc = iterator->Next();
if (arc->start == n1 && arc->end == n2) found = true;
}
delete iterator;
return (found);
}
|