|
-
August 19th, 1999, 06:55 AM
#1
polimorfism
Hi,
I'm looking for information about the way of
redefine class parent methods in children. The instruction
implements seems to be used to implement polimorfism, but
i don't know how does it work. All the examples i've seen use
different names to codify children methods so, how can parent know
what's the method he needs to execute depending on child type?
thanks.
-
August 19th, 1999, 07:06 AM
#2
Re: polimorfism
The idea behind polymorphism is that classes can 'implement' a standard interface (or many different interfaces).
eg.
Class Animal - leave empty - it's just an interface
option Explicit
'
public Sub MakeNoise()
'
End Sub
Class Dog
option Explicit
'
Implements Animal
'
private Sub Animal_MakeNoise()
MsgBox "Woof"
End Sub
Class Mouse
option Explicit
'
Implements Animal
'
private Sub Animal_MakeNoise()
MsgBox "Eek!"
End Sub
Your 'parent' object can then instantiate these objects as follows :
Dim oMouse as Animal
Dim oDog as Animal
'
set oMouse = new Mouse
set oDog = new Dog
'
oMouse.MakeNoise
oDog.MakeNoise
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|