use unintialized_copy where is initialized

Discussion in 'C++' started by Stanley Rice, Feb 18, 2012.

  1. Stanley Rice

    Stanley Rice Guest

    `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.
    Stanley Rice, Feb 18, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattB
    Replies:
    3
    Views:
    54,688
    nada111
    Oct 4, 2007
  2. Marc Fauser

    Variables not initialized

    Marc Fauser, Jul 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    359
    Natty Gur
    Jul 7, 2004
  3. CJM
    Replies:
    2
    Views:
    4,504
  4. Replies:
    7
    Views:
    91
    Anno Siegel
    May 20, 2006
  5. kj
    Replies:
    2
    Views:
    137
    John Bokma
    Jan 2, 2008
Loading...

Share This Page