I wonder how this code could work:
struct my_array
{
int r[1000];
};
int main()
{
my_array foo, bar;
foo = bar;
}
Because the foo = bar call will invoke the constructor-provided operator= for the class, which will lazily apply it on every members. But arrays don't have an implementation for operator=, proof is, this code fails to compile:
int main()
{
int a[1000], b[1000];
a = b;
}
So how come my first code compiles?
structs, likeclasses, do have a defaultoperator=that copies each member.operator=is invoked, which will in turn applyoperator=on every member, my question is: how does this work given arrays don't haveoperator=(i.e. can't be copied)operator=copies each member. It doesn't necessarily calloperator=on them unless that's the appropriate way to copy them. Why should astructwithint r[2];copy differently from astructwithint r1, r2;?