C++ 模板类链表迭代器与list.h迭代器基本介绍

C++ 模板类链表迭代器与<list.h>迭代器基本介绍
本程序基于本博客C++模板类链表基础上实现
主程序 main.cpp

//Written by Xuebi
//本程序使用模板类创建链表,并实现添加数据,删除数据,反转链表,连接链表功能
//本程序在实现以上功能的前提下,一方面介绍了系统自带的list类,并演示了基本操作,另一方面,在上篇博客的基础上增加了自己设计的迭代器。
//系统的迭代器和额外编写的迭代器使得能对连边里面的数据进行具体的操作,值得注意的是,系统自带的list类功能当然更加完善
#include <iostream>
#include "List.h"
#include <list>
using namespace std;
int main()
{
    cout<<"The first part is the List class saved in the system: ";
    std:list<int> ListSystem;
    ListSystem.push_front(10);//往链头输入数据interger 10
    ListSystem.push_front(20);//往链头输入数据interger 20
    ListSystem.push_front(30);//往链头输入数据interger 30
    ListSystem.push_front(40);//往链头输入数据interger 40
    ListSystem.push_back(0);//往链尾输入数据interger 0
    std::list<int>::iterator i=ListSystem.begin();//讲链表开头的地址赋值与迭代器 i
    cout<<*i;
    i++;
    while(i!=(ListSystem.end()))
    {
        cout<<"->";
        cout<<*i;
        ++i;
    }
    cout<<endl;
    cout<<"The following is written by myself:"<<endl;
    List<int> st;
    st.Insert(10);
    st.Insert(20);
    st.Insert(30);
    st.Insert(40);
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值