`
lobin
  • 浏览: 418080 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

第31章 C++ STL

 
阅读更多

STL

写道
The C++ STL (Standard Template Library) is a generic collection of class templates and
algorithms that allow programmers to easily implement standard data structures like
queues, lists, and stacks.

 

Iterator 

STL中所有提供的集合类模板都提供一种遍历访问的方式,即遍历器,这是一种很方便的遍历集合中元素的设计模式。

 

这这些集合类模板中,和Iterator使用有关的两个重要的方法就是begin()和end()。和这两个方法类似的还有cbegin()和cend(),以及rbegin()和rend()。这些方法都返回一个对应的Iterator。

 

其中,cbegin()和cend(),和begin()以及end()不一样的是,它们返回一个const_iterator。而rbegin()和rend()返回一个reverse_iterator。

 

不同的集合类模板返回的Iterator也不一样,如list和map返回的Iterator定义也不一样。

 

list

 

构造函数

    list()

        noexcept(is_nothrow_default_constructible<allocator_type>::value);

    explicit list(const allocator_type& a);

 

    explicit list(size_type n);

    explicit list(size_type n, const allocator_type& a); // C++14

 

    list(size_type n, const value_type& value);

    list(size_type n, const value_type& value, const allocator_type& a);

 

    template <class Iter>

        list(Iter first, Iter last);

    template <class Iter>

        list(Iter first, Iter last, const allocator_type& a);

 

    list(const list& x);

    list(const list&, const allocator_type& a);

 

    list(list&& x)

        noexcept(is_nothrow_move_constructible<allocator_type>::value);

    list(list&&, const allocator_type& a);

 

    list(initializer_list<value_type>);

    list(initializer_list<value_type>, const allocator_type& a);

 

 

std::list<int> list;

 

std::list<int> list2(5);

 

std::list<int> list2(5, 10);

 

std::list<int> list2(5, 10);

std::list<int> list3(list2.begin(), list2.end());

 

std::list<int> list2(5, 10);

std::list<int> list4(list2);

 

std::list<int> list2(5, 10);

std::list<int> list5(std::move(list2));

 

int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

std::list<int> list6(a, a + 10);

 

  std::list<int> list;

  list.assign(10, 10);

 

  std::list<int> list;

  for (int i = 0; i < 10; i++)

  {

    list.push_back(10);

  }

 

  std::list<int> list;

  std::list<int>::iterator it;

 

  it = list.begin();

  for (int i = 0; i < 10; i++)

  {

    list.insert(it, i);

  }

 

遍历

  for (std::list<int>::iterator it = list.begin(); it != list.end(); it++)

  {

    std::cout<<*it<<std::endl;

  }

 

定义

 

template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
class _LIBCPP_TYPE_VIS_ONLY list
    : private __list_imp<_Tp, _Alloc>
{
    typedef __list_imp<_Tp, _Alloc> base;
    typedef typename base::__node              __node;
    typedef typename base::__node_allocator    __node_allocator;
    typedef typename base::__node_pointer      __node_pointer;
    typedef typename base::__node_alloc_traits __node_alloc_traits;
    typedef typename base::__node_base         __node_base;
    typedef typename base::__node_base_pointer __node_base_pointer;
    typedef typename base::__link_pointer __link_pointer;

public:
    typedef _Tp                                      value_type;
    typedef _Alloc                                   allocator_type;
    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
                  "Invalid allocator::value_type");
    typedef value_type&                              reference;
    typedef const value_type&                        const_reference;
    typedef typename base::pointer                   pointer;
    typedef typename base::const_pointer             const_pointer;
    typedef typename base::size_type                 size_type;
    typedef typename base::difference_type           difference_type;
    typedef typename base::iterator                  iterator;
    typedef typename base::const_iterator            const_iterator;
    typedef _VSTD::reverse_iterator<iterator>         reverse_iterator;
    typedef _VSTD::reverse_iterator<const_iterator>   const_reverse_iterator;

    _LIBCPP_INLINE_VISIBILITY
    list()
        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
    {
#if _LIBCPP_DEBUG_LEVEL >= 2
        __get_db()->__insert_c(this);
#endif
    }
    _LIBCPP_INLINE_VISIBILITY
    explicit list(const allocator_type& __a) : base(__a)
    {
#if _LIBCPP_DEBUG_LEVEL >= 2
        __get_db()->__insert_c(this);
#endif
    }
    explicit list(size_type __n);
#if _LIBCPP_STD_VER > 11
    explicit list(size_type __n, const allocator_type& __a);
#endif
    list(size_type __n, const value_type& __x);
    list(size_type __n, const value_type& __x, const allocator_type& __a);
    template <class _InpIter>
        list(_InpIter __f, _InpIter __l,
             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
    template <class _InpIter>
        list(_InpIter __f, _InpIter __l, const allocator_type& __a,
             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);

    list(const list& __c);
    list(const list& __c, const allocator_type& __a);
    list& operator=(const list& __c);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
    list(initializer_list<value_type> __il);
    list(initializer_list<value_type> __il, const allocator_type& __a);
#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    list(list&& __c)
        _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
    list(list&& __c, const allocator_type& __a);
    list& operator=(list&& __c)
        _NOEXCEPT_(
            __node_alloc_traits::propagate_on_container_move_assignment::value &&
            is_nothrow_move_assignable<__node_allocator>::value);
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
    _LIBCPP_INLINE_VISIBILITY
    list& operator=(initializer_list<value_type> __il)
        {assign(__il.begin(), __il.end()); return *this;}
#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

    template <class _InpIter>
        void assign(_InpIter __f, _InpIter __l,
             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
    void assign(size_type __n, const value_type& __x);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
    _LIBCPP_INLINE_VISIBILITY
    void assign(initializer_list<value_type> __il)
        {assign(__il.begin(), __il.end());}
#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

    allocator_type get_allocator() const _NOEXCEPT;

    _LIBCPP_INLINE_VISIBILITY
    size_type size() const _NOEXCEPT     {return base::__sz();}
    _LIBCPP_INLINE_VISIBILITY
    bool empty() const _NOEXCEPT         {return base::empty();}
    _LIBCPP_INLINE_VISIBILITY
    size_type max_size() const _NOEXCEPT
        {return numeric_limits<difference_type>::max();}

    _LIBCPP_INLINE_VISIBILITY
          iterator begin() _NOEXCEPT        {return base::begin();}
    _LIBCPP_INLINE_VISIBILITY
    const_iterator begin()  const _NOEXCEPT {return base::begin();}
    _LIBCPP_INLINE_VISIBILITY
          iterator end() _NOEXCEPT          {return base::end();}
    _LIBCPP_INLINE_VISIBILITY
    const_iterator end()    const _NOEXCEPT {return base::end();}
    _LIBCPP_INLINE_VISIBILITY
    const_iterator cbegin() const _NOEXCEPT {return base::begin();}
    _LIBCPP_INLINE_VISIBILITY
    const_iterator cend()   const _NOEXCEPT {return base::end();}

    _LIBCPP_INLINE_VISIBILITY
          reverse_iterator rbegin() _NOEXCEPT
            {return       reverse_iterator(end());}
    _LIBCPP_INLINE_VISIBILITY
    const_reverse_iterator rbegin()  const _NOEXCEPT
        {return const_reverse_iterator(end());}
    _LIBCPP_INLINE_VISIBILITY
          reverse_iterator rend() _NOEXCEPT
            {return       reverse_iterator(begin());}
    _LIBCPP_INLINE_VISIBILITY
    const_reverse_iterator rend()    const _NOEXCEPT
        {return const_reverse_iterator(begin());}
    _LIBCPP_INLINE_VISIBILITY
    const_reverse_iterator crbegin() const _NOEXCEPT
        {return const_reverse_iterator(end());}
    _LIBCPP_INLINE_VISIBILITY
    const_reverse_iterator crend()   const _NOEXCEPT
        {return const_reverse_iterator(begin());}

    _LIBCPP_INLINE_VISIBILITY
    reference front()
    {
        _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
        return base::__end_.__next_->__as_node()->__value_;
    }
    _LIBCPP_INLINE_VISIBILITY
    const_reference front() const
    {
        _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
        return base::__end_.__next_->__as_node()->__value_;
    }
    _LIBCPP_INLINE_VISIBILITY
    reference back()
    {
        _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
        return base::__end_.__prev_->__as_node()->__value_;
    }
    _LIBCPP_INLINE_VISIBILITY
    const_reference back() const
    {
        _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
        return base::__end_.__prev_->__as_node()->__value_;
    }

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    void push_front(value_type&& __x);
    void push_back(value_type&& __x);
#ifndef _LIBCPP_HAS_NO_VARIADICS
    template <class... _Args>
       void emplace_front(_Args&&... __args);
    template <class... _Args>
        void emplace_back(_Args&&... __args);
    template <class... _Args>
        iterator emplace(const_iterator __p, _Args&&... __args);
#endif  // _LIBCPP_HAS_NO_VARIADICS
    iterator insert(const_iterator __p, value_type&& __x);
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    void push_front(const value_type& __x);
    void push_back(const value_type& __x);

    iterator insert(const_iterator __p, const value_type& __x);
    iterator insert(const_iterator __p, size_type __n, const value_type& __x);
    template <class _InpIter>
        iterator insert(const_iterator __p, _InpIter __f, _InpIter __l,
             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
    _LIBCPP_INLINE_VISIBILITY
    iterator insert(const_iterator __p, initializer_list<value_type> __il)
        {return insert(__p, __il.begin(), __il.end());}
#endif   // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

    _LIBCPP_INLINE_VISIBILITY
    void swap(list& __c)
#if _LIBCPP_STD_VER >= 14
        _NOEXCEPT
#else
        _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
                   __is_nothrow_swappable<__node_allocator>::value)
#endif
        {base::swap(__c);}
    _LIBCPP_INLINE_VISIBILITY
    void clear() _NOEXCEPT {base::clear();}

    void pop_front();
    void pop_back();

    iterator erase(const_iterator __p);
    iterator erase(const_iterator __f, const_iterator __l);

    void resize(size_type __n);
    void resize(size_type __n, const value_type& __x);

    void splice(const_iterator __p, list& __c);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    void splice(const_iterator __p, list&& __c) {splice(__p, __c);}
#endif
    void splice(const_iterator __p, list& __c, const_iterator __i);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    void splice(const_iterator __p, list&& __c, const_iterator __i)
        {splice(__p, __c, __i);}
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
    void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l)
        {splice(__p, __c, __f, __l);}
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    void remove(const value_type& __x);
    template <class _Pred> void remove_if(_Pred __pred);
    void unique();
    template <class _BinaryPred>
        void unique(_BinaryPred __binary_pred);
    void merge(list& __c);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    void merge(list&& __c) {merge(__c);}
#endif
    template <class _Comp>
        void merge(list& __c, _Comp __comp);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    template <class _Comp>
    _LIBCPP_INLINE_VISIBILITY
        void merge(list&& __c, _Comp __comp) {merge(__c, __comp);}
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
    void sort();
    template <class _Comp>
        void sort(_Comp __comp);

    void reverse() _NOEXCEPT;

    bool __invariants() const;

#if _LIBCPP_DEBUG_LEVEL >= 2

    bool __dereferenceable(const const_iterator* __i) const;
    bool __decrementable(const const_iterator* __i) const;
    bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;

#endif  // _LIBCPP_DEBUG_LEVEL >= 2

private:
    static void __link_nodes  (__link_pointer __p, __link_pointer __f, __link_pointer __l);
    void __link_nodes_at_front(__link_pointer __f, __link_pointer __l);
    void __link_nodes_at_back (__link_pointer __f, __link_pointer __l);
    iterator __iterator(size_type __n);
    template <class _Comp>
        static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);

    void __move_assign(list& __c, true_type)
        _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value);
    void __move_assign(list& __c, false_type);
};

map

  std::map<char*, int> map;

  map["key1"] = 1;

  map["key2"] = 2;

  map["key3"] = 3;

  map["key4"] = 4;

  map["key5"] = 5;

  map["key6"] = 6;

 

bool compare(char* left, char* right) 

{

  return strcmp(left, right);

}

 

  std::map<char *, int, bool (*) (char*, char*)> map2(compare);

  map2["key1"] = 10;

  map2["key2"] = 20;

  map2["key3"] = 30;

  map2["key4"] = 40;

  map2["key5"] = 50;

  map2["key6"] = 60;

 

struct compare_st

{

  bool operator() (char* left, char* right) const

  {

    return strcmp(left, right);

  }

};

 

  std::map<char *, int, compare_st> map3;

  map3["key1"] = 100;

  map3["key2"] = 200;

  map3["key3"] = 300;

  map3["key4"] = 400;

  map3["key5"] = 500;

  map3["key6"] = 600;

 

class Compare

{

  public: bool operator() (char* left, char* right) const

  {

    return strcmp(left, right);

  }

};

 

  std::map<char *, int, Compare> map4;

  map4["key1"] = 1000;

  map4["key2"] = 2000;

  map4["key3"] = 3000;

  map4["key4"] = 4000;

  map4["key5"] = 5000;

  map4["key6"] = 6000;

 

 

  std::map<char *, int> map1;

  map1["key1"] = 1;

  map1["key2"] = 2;

  map1["key3"] = 3;

  map1["key4"] = 4;

  map1["key5"] = 5;

  map1["key6"] = 6;

  std::map<char *, int> map5(map1.begin(), map1.end());

 

  std::map<char *, int> map1;

  map1["key1"] = 1;

  map1["key2"] = 2;

  map1["key3"] = 3;

  map1["key4"] = 4;

  map1["key5"] = 5;

  map1["key6"] = 6;

  std::map<char *, int, bool (*) (char*, char*)> map6(map1.begin(), map1.end(), compare);

 

  std::map<char *, int> map1;

  map1["key1"] = 1;

  map1["key2"] = 2;

  map1["key3"] = 3;

  map1["key4"] = 4;

  map1["key5"] = 5;

  map1["key6"] = 6;

  std::map<char *, int, compare_st> map7(map1.begin(), map1.end());

 

  std::map<char *, int> map1;

  map1["key1"] = 1;

  map1["key2"] = 2;

  map1["key3"] = 3;

  map1["key4"] = 4;

  map1["key5"] = 5;

  map1["key6"] = 6;

  std::map<char *, int, Compare> map8(map1.begin(), map1.end());

 

  std::map<char *, int> map1;

  map1["key1"] = 1;

  map1["key2"] = 2;

  map1["key3"] = 3;

  map1["key4"] = 4;

  map1["key5"] = 5;

  map1["key6"] = 6;

  std::map<char *, int> map6(map1);

 

  std::map<char *, int> map1;

  map1["key1"] = 1;

  map1["key2"] = 2;

  map1["key3"] = 3;

  map1["key4"] = 4;

  map1["key5"] = 5;

  map1["key6"] = 6;

std::map<char *, int> map10(std::move(map1));

 

遍历

  for (std::map<char *, int>::iterator it = map.begin(); it != map.end(); it++)

  {

    std::cout<<it->first<<"=>"<<it->second<<std::endl;

  }

队列

 

queue

 

  std::queue<int> queue1;

 

  for (int i = 0; i < 10; i++)

  {

    queue1.push(i);

  }

 

  while (! queue1.empty()) 

  {

    std::cout<<queue1.front()<<std::endl;

    queue1.pop();

  }

 

优先级队列

 

priority_queue

 

  std::priority_queue<int> queue1;

 

  for (int i = 0; i < 10; i++)

  {

    queue1.push(i);

  }

 

  while (! queue1.empty()) 

  {

    std::cout<<queue1.top()<<std::endl;

    queue1.pop();

  }

 

 

 

 

 

 

分享到:
评论

相关推荐

    C++ STL 开发技术导引(第6章)

    第三篇 C++ STL容器技术 第6章 vector向量容器 92 6.1 vector技术原理 92 6.2 vector应用基础 94 6.3 本章小结 101 第7章 deque双端队列容器 102 7.1 deque技术原理 102 7.2 deque应用基础 108 7.3 ...

    C++ STL开发技术导引(第5章)

    第三篇 C++ STL容器技术 第6章 vector向量容器 92 6.1 vector技术原理 92 6.2 vector应用基础 94 6.3 本章小结 101 第7章 deque双端队列容器 102 7.1 deque技术原理 102 7.2 deque应用基础 108 7.3 ...

    C++ STL开发技术导引(第3章)

    第三篇 C++ STL容器技术 第6章 vector向量容器 92 6.1 vector技术原理 92 6.2 vector应用基础 94 6.3 本章小结 101 第7章 deque双端队列容器 102 7.1 deque技术原理 102 7.2 deque应用基础 108 7.3 ...

    C++ stl算法汇总(C++程序员必备)

    C++ STL(Standard Template Library,标准模板库)是C++编程中极其重要的组成部分,它提供了一组高效且灵活的算法,用于处理各种数据结构,如向量、列表、集合等。这些算法通常与容器(如vector、list)配合使用,...

    C++ STL 编程速查宝典

    预处理器指令是C++编译过程的第一步,它允许在实际编译之前对源代码进行修改,包括宏定义、头文件包含、条件编译等。例如,`#include &lt;stdio.h&gt;`用于引入标准输入输出库,而`#define X someText`则用于创建宏定义,...

    C++STL实验报告-迭代器和非变异算法

    实验还涉及到第8章的部分例题,虽然具体代码未给出,但通常会涉及更复杂的操作,如使用算法对容器进行排序、查找、合并等。非变异算法如`find_if`、`lower_bound`、`upper_bound`等在这些操作中扮演重要角色,它们...

    高质量c++编程指南 第三版

    内容简介回到顶部↑高质量软件开发是国内计算机教育的薄弱环节,很多程序员虽然能熟练地掌握编程技术但是缺乏强烈的质量意识,不懂得在开发过程中内建高质量。...第三部分 附录 附录 A:C++/C 试题

    C++Primer 第四版课后习题解答(第1~18章完整答案)完整版

    第三章“标准库类型”讲解了C++标准库中的基本类型,如iostream用于输入输出,string用于处理字符串,vector和array作为动态数组。习题解答会涉及这些类型的使用方法,例如流操作、字符串操作、容器的增删改查等。 ...

    《高质量程序设计指南》林锐.rar

    第十一章 内存管理 第十二章 C++函数的高级特性 第十三章 类的构造函数、析构函数与赋值函数 第十四章 C++ STL应用编程建议 第十五章 其它编程经验 参考文献 第三部分 附录 附录 A:C++/C 试题 附录 B:C++/C 试题的...

    c++初学入门

    第三课题:c++语言的基本语句及顺序结构的程序设计 第四课题:c++语言的控制结构选择结构的程序设计 第五课题:c++语言的控制结构循环结构的程序设计 第六课题:c++数组 第七课题:c++函数 第八课题:c++结构体 第九...

    C++中STL使用总结

    C++ STL是C++标准模板库(Standard Template Library)的简称,它提供了常见的数据结构和算法的实现。STL不仅限于C++,C语言中也有相应的库来实现STL的功能,但是C++的STL功能更为强大和方便。在C++中,STL主要包含...

    难得干货好课程!最新完结版C++全栈开发视频教程 最新版本C++从零基础到精通课程

    08_第8章_STL详解 09_第9章_Qt图形界面开发 课程全部目录(未全部列出) (1)\源码+笔记+课件 (2)\视频 (3)\源码+笔记+课件 ├─代码.zip ├─教案.zip ├─笔记.zip (4)\视频\01_第1章_c++概述;目录中文件数:3...

    c++教学课件 PPT(共十章)

    第三章:函数 函数是C++中组织代码的基本单元。本章会讲解函数的定义、调用、参数传递、返回值等概念,以及函数重载和递归函数的应用。 第四章:数组和指针 数组是存储同类型数据集合的结构,而指针则是存储内存...

    C++大学教程第五版 课后答案 第12-21章

    《C++大学教程第五版》是一本广泛应用于教学和自学的C++编程教材,其课后答案涵盖了第12至21章的内容,这十个章节是深入理解和掌握C++编程的关键部分。以下将对这些章节涉及的主要知识点进行详细阐述。 第12章:类...

    c++课后答案郑丽,董渊编著

    2. **第三章 函数**:函数是C++中实现模块化编程的核心,介绍了函数的定义、调用、参数传递和返回值,以及重载函数的概念,让代码更加有序和可复用。 3. **第四章 类**:类是面向对象编程的基础,本章详细解释了类...

    Professional C++

    - 第三章:“编码风格”,讲述了如何编写高质量、易于维护的C++代码,强调了编程风格和代码规范的重要性。 第二部分:“专业C++软件设计” - 第四章:“设计专业的C++程序”,讨论了良好的软件设计原则,强调如何...

    三十分钟掌握STL

    ### 三十分钟掌握STL:理解数据结构与算法的分离 #### STL简介 标准模板库(Standard Template Library,简称STL)是C++标准库的一部分,由一系列模板类和函数组成,提供了高效的容器、迭代器以及算法等工具,极大...

    皮德常C++课件

    【第三章】可能会讲解函数的使用,包括函数的定义、调用、参数传递以及返回值。此外,还有内置函数(如sqrt、pow等)的使用,以及如何自定义函数来提高代码的复用性。 【第四章】通常会涉及数组和指针,这是C++中...

    C++Primer(第4版)-课后习题答案.pdf

    3. 第三章标准库类型:介绍C++标准库中的容器,如`std::string`用于处理字符串,`std::complex`用于复数运算,以及`std::stringstream`用于文本流处理。 4. 第四章数组和指针:讨论一维和多维数组,以及指针的概念...

    c++primer第五版第9章课后习题答案(下)

    这些习题答案涵盖了从第31题到第46题,旨在帮助读者巩固并深入理解这些主题。下面,我们将详细探讨这些题目涉及的知识点。 1. **模板** (9.31.cpp, 9.34.cpp, 9.43.cpp) - 模板是C++中的泛型编程工具,可以用于...

Global site tag (gtag.js) - Google Analytics