Well, I have understood bit-wise copy very well but still not getting my hands on deep copy. I have understood the mechanism, but not able to implement it in a program.
I am trying following code.
obvious reason is, I dint copy data in copy constructor hence it is giving value 0 instead of 20
so I try something like
1 2 3 4 5 6
array(array& object)
{
//previous code then
copy(copy.data,copy.data+copy.size,data); //which is not correct syntax but I
//don't know how to copy data
}
so I get an error like
explicit_copy_constructor.cpp:37:12: error: ‘std::copy’ does not have class type
could somebody please let me know how should I make value of copy.data[0] 20?
Thanks in advance.
This topic discusses some alternative ways to copy arrays. I wouldn't mind the actual time benchmarking [especially mine because apparently they were bogus], but I thought I'd link it because of the code examples.
@bluecoder :perfect ! thanks a lot. It now works. :)
@johnbob - do I need to include any header file for memcpy (I guess it is a C function, though not sure). It gives the error, error: ‘memcpy’ was not declared in this scope
Thanks in advance.