MCPcopy Create free account
hub / github.com/EricPengShuai/Interview / Vector

Method Vector

base_code/template.cpp:161–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159{
160public:
161 Vector(int size = 10)
162 {
163 // 需要把内存开辟和对象构造分开处理, 不能是直接 _first = new T[size]
164 // 因为 new 既分配空间又会调用相应的构造函数, 实际上这里只需要分配空间
165 _first = _allocator.allocate(size);
166 _last = _first;
167 _end = _first + size;
168 }
169
170 ~Vector()
171 {

Callers

nothing calls this directly

Calls 2

allocateMethod · 0.80
constructMethod · 0.80

Tested by

no test coverage detected