Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Does vfp support polymorphism?
Message
 
To
20/06/2003 06:14:28
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turkey
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00802118
Message ID:
00802465
Views:
21
Here is a very weak example (because Fox is a weakly typed language).
circ = CREATEOBJECT("circle")
drawsomething(circ)

FUNCTION drawsomething (ashape as myshape)
ashape.draw()
endfunc

DEFINE CLASS myshape as Custom
	PROCEDURE draw
		?"draw shape"
	endproc
enddefine

DEFINE CLASS circle as myshape
	PROCEDURE draw
		?"draw circle"
		DODEFAULT()
	endproc
ENDDEFINE
prints
"draw circle"
"draw shape"

The point is that you instantiate an instance of a subclass, pass it to some method that only knows about the parent and when it calls a method of the passed object you get the subclassed behavior, not the parent behavior. We know that we passed it a circle, but the function only had to know about an abstract shape. Next time we pass it a square we dont have to modify the drawsomthing method, polymorphism makes sure we get the correct behavior.

Polymorphism is what gives us frameworks and low coupling.

>i have gone i java course lastdays. i couldn't learned java (it confused me) but i learned polymorphism. does vfp support polymorphism if answer yes how?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform