T
Thomas Lorenz
Hi
I have a class Person and a class Student which inherits from Person. Each
class should have a method which copies the properties from another Person
or Student respectively. The copy-method of Student should override the one
of Person and call it as well.
It should look like this (which won't compile):
class Person
{
public virtual void CopyFrom(Person source)
{
//Copy properties
}
}
class Student : Person
{
public override void CopyFrom(Student source)
{
//Copy Student properties
}
}
If I don't use the virtual/override modifiers then I have an overload copy
method in Student which i don't want. There should only be one method in
each class with the according parameter.
How would I do that?
Thank you
I have a class Person and a class Student which inherits from Person. Each
class should have a method which copies the properties from another Person
or Student respectively. The copy-method of Student should override the one
of Person and call it as well.
It should look like this (which won't compile):
class Person
{
public virtual void CopyFrom(Person source)
{
//Copy properties
}
}
class Student : Person
{
public override void CopyFrom(Student source)
{
//Copy Student properties
}
}
If I don't use the virtual/override modifiers then I have an overload copy
method in Student which i don't want. There should only be one method in
each class with the according parameter.
How would I do that?
Thank you