I have a parent and child type and each has a copy() method. I want the child copy() to call the parent copy() and then do it's own additional copying. I have something like this:
[CODE]
Type TParent
field age : int
method copy : TParent()
parent : TParent = new TParent
parent.age = age
return parent
end method
End Type
Type TChild extends TParent
field grade : int
method copy : TChild()
child : TChild = new TChild
child = TChild( super.copy() ) '<------- problem line
child.grade = grade
return child
end method
end Type
[/CODE]
The problem is in my TChild copy() the child that is assigned from the TChild typecast always comes out null.
Any help on why it doesn't work or another method for doing these kinds of copy() methods from extended types.
[CODE]
Type TParent
field age : int
method copy : TParent()
parent : TParent = new TParent
parent.age = age
return parent
end method
End Type
Type TChild extends TParent
field grade : int
method copy : TChild()
child : TChild = new TChild
child = TChild( super.copy() ) '<------- problem line
child.grade = grade
return child
end method
end Type
[/CODE]
The problem is in my TChild copy() the child that is assigned from the TChild typecast always comes out null.
Any help on why it doesn't work or another method for doing these kinds of copy() methods from extended types.