比如两个类:class VedioPlayer
sub play(file)
messagebox.show("这个是基类play")
end sub
classclass SwfPlayer
Inherits VedioPlayer
sub play()
messagebox.show("SwfPlayer.play")
end sub
class
然后调用代码如下:dim player as VedioPlayer
dim sPlayer as new SwfPlayer
player.play()
执行player.play()这句时,怎么才可以让他调到SwfPlayer.play?
当然.我知道.用sPlayer.play()可以执行它.
sub play(file)
messagebox.show("这个是基类play")
end sub
classclass SwfPlayer
Inherits VedioPlayer
sub play()
messagebox.show("SwfPlayer.play")
end sub
class
然后调用代码如下:dim player as VedioPlayer
dim sPlayer as new SwfPlayer
player.play()
执行player.play()这句时,怎么才可以让他调到SwfPlayer.play?
当然.我知道.用sPlayer.play()可以执行它.
这样去创建就可以了
sPlayer没存在的必要
vp.play();
VedioPlayer vp;这个做为全局变量.然后根据文件类型的不同,new出不同的Player(有rmPlayer,aviPlayer等,都是从VedioPlayer派生),实例之后,统一用vp这个全局变量中存放。以后的操作就直接对vp操作即可。
但现调用vp.play的话,就只执行基类的play,子类的play无法执行.难道又得将他它转换成相应的子类类型再调用?