main.cpp
来自「异质链表 的实现 实现异质链表的查找、插入、删除和遍历」· C++ 代码 · 共 32 行
CPP
32 行
#include "HeterList.h"
#include "IntNode.h"
#include "FloatNode.h"
#include "StringNode.h"
#include "iostream.h"
int main(int args,char* argv[])
{
CHeterList List;
List.AddNode(new CIntNode(1) );
List.AddNode(new CFloatNode((float)2.01));
List.AddNode(new CFloatNode(2));
List.AddNode(new CStringNode("hello"));
List.VisitAllNode();
bool find=List.FindNode(CIntNode(2));
if(find)
cout << "find int 2 ok" << endl;
else
cout << "find int 2 failed" << endl;
find=List.FindNode(CFloatNode(2));
if(find)
cout << "find float 2 ok" << endl;
else
cout << "find float 2 failed" << endl;
List.DeleteNode(CFloatNode((float)2.01));
List.VisitAllNode();
List.DeleteNode(CIntNode(1));
List.VisitAllNode();
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?