Tuesday, 15 April 2014

memory management - convert malloc to new c++ for struct -



memory management - convert malloc to new c++ for struct -

i have struct:

struct problem { int length; struct node **x; };

and created struct of struct this:

struct problem prob;

i can in c:

prob.x = malloc(struct node *,prob.length);

but how can in c++ style new ? , why ?

in c++, achieved this.

std::vector<node *> problem(length);

the code show emulating little subset of features of vector. namely, array-like container aware of size.

c++ memory-management malloc

No comments:

Post a Comment