 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
Notice
why a “first” and “second” shouldn’t be data members:
|
|
bool
list::operator == (const list & l2) const {
|
|
node * first = head;
|
|
node * second = l2.head;
|
|
while (first && second
&& first->obj == second->obj) {
|
|
first = first->next;
|
|
second = second->next;
|
|
}
|
|
if (first || second) return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
Evaluate
the efficiency of the following:
|
|
|
bool
list::operator != (const list & l2) const {
|
|
return !(*this == l2);
|
|
}
|
|