您的位置:程序门 -> c/c++ -> c++ 语言



stl迭代器的实现问题。。


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


stl迭代器的实现问题。。[已结贴,结贴人:silendream]
发表于:2008-01-21 22:18:52 楼主
下面是从msdn上截取的一段stl中vector   的定义~
能帮我解释一下这些typedef定义的意思和他们是如何实现的么?
c/c++ code
template<class t, class a = allocator<t> > class vector { public: typedef a allocator_type; typedef a::size_type size_type; typedef a::difference_type difference_type; typedef a::reference reference; typedef a::const_reference const_reference; typedef a::value_type value_type; typedef t0 iterator; typedef t1 const_iterator; typedef reverse_iterator<iterator, value_type, reference, a::pointer, difference_type> reverse_iterator;
发表于:2008-01-21 22:23:231楼 得分:2
实现具体看代码。
发表于:2008-01-21 22:24:112楼 得分:2
typedef定义了一个类型,你需要知道allocator的实现.,
发表于:2008-01-21 23:15:123楼 得分:2
全是allocator <t> 里的东西,typedef简化了名称
发表于:2008-01-21 23:16:154楼 得分:2
需要了解就去直接看源码再翻翻《stl源码剖析》吧
发表于:2008-01-22 23:02:395楼 得分:2
其实是2年前看的《stl源码剖析》,最近用也没注意去想底层的东西~~所以忘差不多了~~但是这些都是用typedef定义把名字简化了而已~~~没多大的含义
发表于:2008-01-23 08:59:106楼 得分:0
谢谢各位     我会看的~~


快速检索

最新资讯
热门点击