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.
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 ...
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.
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.
Ok, thanks. By the way, what is assembly?