C++: Reallocating memory without cstdlib -


couldn't find exact answer question:

is freeing memory , allocating again way reallocate memory without using cstdlib? if not so, possible solutions?

thanks in advance.

if implementing own vector class, need copy contents of vector, not use realloc, since don't know object doing when being copied (or in c++11 relevant cases, moved). imagine example have object this:

class b;  class {   private:     b* bp;   public:     a(b *p) : bp(p)     {     } };   class b {   public:    a;    b() : a(this)    {       ...     }  };  myvector<b> v;  

if copy object different address, without calling constructor, bp pointer in a point "random" place. pretty nasty bug try find.

[and yes, there bunch of stuff missing in above classes - not meant complete class declaration, etc, etc]


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -