The Vector will be a first-class type,meaning that unlike the primitive array in C++,the Vector can be cpoied,and the memory it uses can be automatically reclaimed(via its destructor).
First,recall some important fetures of C++ primitive arrays:
(1):The array is simply a pointer variable to a block of memory;the autual array size must be
maintained separately by the programmer.
(2):The block of memory can be allocated via new[],but then must be free via delete[].
(3):The block of memory can not be resize
Now,outline the main details of Vector:
well,go to read the source code,it's very simple ^_^
C++ Vector 实现
本文介绍了一个简单的 C++ Vector 类实现。该 Vector 类支持动态数组的功能,并具备拷贝构造、赋值运算符重载等特性。文章详细展示了如何通过模板实现 Vector 类,包括内存分配、释放、扩容以及迭代器的支持。
2604

被折叠的 条评论
为什么被折叠?



