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
Printable View
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
Thanks for your reply. I know what would happen if I use dynamic memory. What about arrays allocated on the stack?Quote:
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];
};
okay thanks =)