nicba -
Thanks for providing a clear example on polymorphism. Dunno where my head was at when I posted, but I bet you could hazard a guess.
A UDT in VB is a User Defined Type, basically a struct in C.
40 Theives-
For your example of polymorphism, VB can do that easily:
Dim theDog As IAnimalDim theCat As IAnimalDim theAnimals As New Collection'''' ojbect creation''Set theDog = New DogSet theCat = New Cat'''' add to our collection''theAnimals.Add theDogtheAnimals.Add theCat'''' iterator for our collection''Dim animal As IAnimalFor Each animal In theAnimals'''' sounds off for each animal''animal.SoundNext'''' explicitly call objects Sound method''theDog.SoundtheCat.Sound'''' clean up''Set theDog = NothingSet theCat = Nothing[/source]Yes, in VB inheritance is very similar to using interfaces...the difficulty is that you have to re-implement all of the parent class/interfaces properties and methods in your derived class..its a big issue within VB (as in it sucks ..).Here is a sample of the Dog code implementing the IAnimal interface:[source]'''' dog.cls''Implements IAnimalPublic Sub IAnimal_Sound()Debug.Print "Woof"End Sub
You have to do that for EVERY method/property of IAnimal..so while Inheritance is supported...the support leaves alot to be desired.
-Z