Are array members copied "by content" by the default copy constructors? Or will I be modifying both "copies" if I modify one of the members like what would happen were they pointers to dynamically allocated memory?
Thanks
Are array members copied "by content" by the default copy constructors? Or will I be modifying both "copies" if I modify one of the members like what would happen were they pointers to dynamically allocated memory?
Thanks
pointers are copied
memory they point - not
so you get two instances pointing same dynamic memory
It is a reason to use vectors
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Thanks for your reply. I know what would happen if I use dynamic memory. What about arrays allocated on the stack?pointers are copied
memory they point - not
so you get two instances pointing same dynamic memory
It is a reason to use vectors
You mean like this:
they'll be copied by valueCode:class test { int a[10]; };
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
okay thanks =)