T
tommy.hinks
I am wondering if anyone knows how compilers auto-generate copy
constructors for PODs. Let me explain what I mean with an example:
struct A
{
int u;
int v;
};
If I were to write the copy constructor for the POD myself, I would
write it like this:
A::A(const A rhs)
: u(rhs.u), v(rhs.v) {}
the main point being that the member variables are initialized upon
creation, and not created and then assigned a value, like this:
A::A(const A rhs)
{
u = rhs.u;
v = rhs.v;
}
Or perhaps some other form of bitwise (shallow) copying is done by the
compiler for auto-generated PODs?
Any thoughs on this?
Thanks,
T
constructors for PODs. Let me explain what I mean with an example:
struct A
{
int u;
int v;
};
If I were to write the copy constructor for the POD myself, I would
write it like this:
A::A(const A rhs)
: u(rhs.u), v(rhs.v) {}
the main point being that the member variables are initialized upon
creation, and not created and then assigned a value, like this:
A::A(const A rhs)
{
u = rhs.u;
v = rhs.v;
}
Or perhaps some other form of bitwise (shallow) copying is done by the
compiler for auto-generated PODs?
Any thoughs on this?
Thanks,
T