Default copy constructor: copying mechanism for array

This is a discussion on Default copy constructor: copying mechanism for array within the C++ Programming forums, part of the General Programming Boards category; Hello, I am wondering how a default copy constructor copies a static array of build-in types. Does it use a ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    5

    Default copy constructor: copying mechanism for array

    Hello,

    I am wondering how a default copy constructor copies a static array of build-in types. Does it use a loop to go through the array to copy each element? In case of array of char, does it use strcpy function?

    Thank you.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    It will copy each element in the array over to the new array (even if you aren't using the entire array). It might use memcpy, or it might use assembly, or it might use something else. It won't use strcpy because it doesn't know that your character array is intended to represent a string and if your array of characters has any embedded null characters strcpy wouldn't work.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    5
    Ok, thanks. By the way, what is assembly?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling copy constructor from template
    By Ancient Dragon in forum C++ Programming
    Replies: 3
    Last Post: 09-28-2005, 01:54 PM
  2. dynamic memory alloccation & returning objects
    By haditya in forum C++ Programming
    Replies: 8
    Last Post: 04-21-2005, 11:55 PM
  3. Need help in classes
    By LBY in forum C++ Programming
    Replies: 11
    Last Post: 11-26-2004, 03:50 AM
  4. Copy constructors and operator=()
    By filler_bunny in forum C++ Programming
    Replies: 13
    Last Post: 08-25-2003, 07:43 AM
  5. Copy Constructor Help
    By Jubba in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2001, 10:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21