/* linked list class */ #include class cell { private: int head; cell *tail; public: cell(int h, cell *t) { head = h; tail = t; } ~cell() { if (tail != NULL) delete(tail); } // accessors int car() { return head; } cell *cdr() { return tail; } void print() { for (cell* c=this;c!=NULL;c=c->tail) cout << c->head << " "; cout << endl; } // what's wrong with this function? // it's supposed to return the last integer (data) in the list int last() { cell * c; c = this; while (c->tail != NULL) c = c->tail; return (int)c; } }; int main(int argc, char **argv) { cell * l; l = new cell(2,new cell(3,new cell(5, new cell(7,NULL)))); cout << l->last() << endl; return 0; }