c++ - Creating an object on the heap without new -
in c++, possible create object on heap without using new or malloc ?
i think if use stl container vector put on heap. if do:
vector<object> listobjs = vector<object>(); object x = object(...); ... listobjs.push_back(x); where objects created here reside?
the object denoted x resides on stack. vector::push_back copy heap.
the allocator object inside vector implemented using new or malloc, although possible uses another, low-level api. instance, both unix , windows offer memory mapping apis, in turn may used implement malloc, new , allocators.
Comments
Post a Comment