I know that if a have class member that its being allocated dynamically
I have to implement copy constructor and use deep copy (usually).
Can I use default copy constructor if I have only staticly allocated memebr?
Say for example I have the following
Can I use the compiler's copy constructor? and if so why I don't need to implement deep copy in order to copy array y?
Thank u in advance
|Can I use the compiler's copy constructor? and if so why I don't need to implement deep copy in order to copy array y?|
Hmm... because there's bitwise copying involved. Which means that data x
are copied entirely.
When you use dynamic allocation, and you have a member
all that is copied is the value of z
is a pointer, so its value represents a memory address. So what is copied is a memory address, not the contents of the pointed-to memory.
Edit: I may be totally wrong. I'll test and see.
Last edited on
Topic archived. No new replies allowed.