S
Stanley Rice
`the difference between *uninitialized_copy* function and *copy* is that the
*uninitialized_copy* function could copy the object at the location where
is uninitialized. For example:
int ia[5] = {1, 2, 3, 4, 5};
int n = sizeof ia / sizeof *ia;
int *ib = (int *)malloc(n * sizeof *ia);
uninitialized_copy(ia, ia + n, ib);
My question is, what if I copy the initialized memory by calling the
uninitialized_copy function. Instead of allocatiing the memory by calling
malloc, I use new.
int *ib = new int[n];
uninitialized_copy(ia, ia + n, ib);
I works too. But am i correct? If so, what's the difference between copy
and uninitialized_copy?
Thanks.
*uninitialized_copy* function could copy the object at the location where
is uninitialized. For example:
int ia[5] = {1, 2, 3, 4, 5};
int n = sizeof ia / sizeof *ia;
int *ib = (int *)malloc(n * sizeof *ia);
uninitialized_copy(ia, ia + n, ib);
My question is, what if I copy the initialized memory by calling the
uninitialized_copy function. Instead of allocatiing the memory by calling
malloc, I use new.
int *ib = new int[n];
uninitialized_copy(ia, ia + n, ib);
I works too. But am i correct? If so, what's the difference between copy
and uninitialized_copy?
Thanks.