G
Guest
I'm probably being dense here. In the following situation:
class Base {
int x;
int y;
}
class Decendant : Base {
int z;
}
I need a function (constructor or whatever) in "Decendant" that will take a
"Base" and do a member-wise copy of "Base"'s members to itself. I know I
could just copy each base member, but I know there's got to be a better way.
I tried the following constructor in Decendant:
public Decendant(Base _base) : base(_base) {
z = 0;
}
The problem is that "Base" doesn't have a constructor that takes an instance
of itself. I'd prefer not to modify "Base", if possible.
I looked at MemberwiseClone, but that doesn't look like what I need.
Thanks in Advance!
Jamie
class Base {
int x;
int y;
}
class Decendant : Base {
int z;
}
I need a function (constructor or whatever) in "Decendant" that will take a
"Base" and do a member-wise copy of "Base"'s members to itself. I know I
could just copy each base member, but I know there's got to be a better way.
I tried the following constructor in Decendant:
public Decendant(Base _base) : base(_base) {
z = 0;
}
The problem is that "Base" doesn't have a constructor that takes an instance
of itself. I'd prefer not to modify "Base", if possible.
I looked at MemberwiseClone, but that doesn't look like what I need.
Thanks in Advance!
Jamie