To determine whether a list has been traversed completely, you define
endp
. The endp
predicate is easy to define, because, when
you work on a pointer with the negation operation, the result is 1, of type
int
, if the pointer is the null pointer; otherwise, the result is 0, of
type int
:
class header { public: link *first_link_pointer; link *current_link_pointer; header ( ) { first_link_pointer = NULL; current_link_pointer = first_link_pointer; } ... int endp ( ) { return ! current_link_pointer; } ... };