View Single Post
Old 03-18-2003, 02:22 PM   #8 (permalink)
Jawn
Registered User
 
Join Date: Mar 2003
Posts: 2
Jawn is on a distinguished road
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);
}
Jawn is offline   Reply With Quote