首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

当链表兑现(C++)

2012-09-28 
当链表实现(C++)C/C++ codeclass IntSLLNode {public:int infoclass IntSLLNode *nextIntSLLNode(int el

当链表实现(C++)

C/C++ code
class IntSLLNode {public:    int info;    class IntSLLNode *next;    IntSLLNode(int el, IntSLLNode *ptr = 0) {        info = el; next = ptr;    }};




C/C++ code
int IntSLList::deleteFromHead() {    int el = head->info;    IntSLLNode *tmp = head;    if (head == tail)              head = tail = 0;    else head = head->next;    delete tmp;    return el;}




我这两段代码片段里的*tmp 有什么用 我怎么觉得没用处?

[解决办法]
那么大的用处居然说没有用?

IntSLLNode *tmp = head;
//明显是要删掉头结点嘛!!

热点排行