S
Sid Price
I have a problem with my class hierarchy at runtime and would appreciate
some input.
I have a base class, let's call it "BaseClass", that has a public function
"ToXML". In BaseClass.ToXML some common parameters are written to an XML
document and the document is returned. In the derived classes I have an
overloaded function that is designed to call the base class to create and
write the common elements to the XML document and then each derived class
writes their elements.
There are also some classes derived from these sub-classes. So we have:
BaseClass -> SubClass_1 -> SubClass_2.
In my application I have a method that may receive anyone of the class
objects in my hierarchy of classes derived from BaseClass so it looks a bit
like this:
public sub WriteOutput(byval oMessage as BaseClass)
oMessage.ToXML()
end sub
What I expect to happen is that late binding will cause the ToXML method in
a derived class to be called. So calling WriteOutput with a SubClass_2
object I expected the SubClass_2.ToXML to be called. What I find is that
BaseClass.ToXML is always called.
I have tried declaring the ToXML methods of derived class both with
"overloads" and with "shadows" and still BaseClass.ToXML is called on all
passed objects.
I would appreciate any help in understanding the correct way to build this
class structure.
Thanks,
Sid.
some input.
I have a base class, let's call it "BaseClass", that has a public function
"ToXML". In BaseClass.ToXML some common parameters are written to an XML
document and the document is returned. In the derived classes I have an
overloaded function that is designed to call the base class to create and
write the common elements to the XML document and then each derived class
writes their elements.
There are also some classes derived from these sub-classes. So we have:
BaseClass -> SubClass_1 -> SubClass_2.
In my application I have a method that may receive anyone of the class
objects in my hierarchy of classes derived from BaseClass so it looks a bit
like this:
public sub WriteOutput(byval oMessage as BaseClass)
oMessage.ToXML()
end sub
What I expect to happen is that late binding will cause the ToXML method in
a derived class to be called. So calling WriteOutput with a SubClass_2
object I expected the SubClass_2.ToXML to be called. What I find is that
BaseClass.ToXML is always called.
I have tried declaring the ToXML methods of derived class both with
"overloads" and with "shadows" and still BaseClass.ToXML is called on all
passed objects.
I would appreciate any help in understanding the correct way to build this
class structure.
Thanks,
Sid.