目录
1.CList.h2.CList.cpp
3.main.cpp
1.CList.h
#ifndef>2.CList.cpp
#include"CList.h" #include<stdio.h> #include<cstring>//memset头文件 CNode::CNode() { > { count++; if(count == pos) { pre->pnext = tmp->pnext; //tmp数据域释放掉 delete tmp->data; delete tmp; return 1; } pre = pre->pnext; tmp = tmp->pnext; } return -1; } //获取节点数据 void* CList::getNodeByPos(int CGjjFpos) { int count = 0; CNode* tmp = head; while(tmp->pnext!=NULL) { count++; tmp = tmp->pnext; if(pos == count) { return tmp->data; } } return NULL; } //释放链表 void* CList::freeList() { CNode* tmp = head; while(tmp!=NULL) { head = head->pnext; delete tmp->data; delete tmp; tmp = head; } return this->head; }3.main.cpp
计算总节点数:
#include<iostream> using>到此这篇关于C++链表类的封装详情介绍的文章就介绍到这了,更多相关C++链表类封装内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!









