ASP 类组合

作者:vkvi 来源:千一网络 日期:2006-5-19

ASP 类的功能实在有限,所以有时我们要实现复杂的功能,只好用组合来实现。

class CFish
    sub Swim()
    end sub
end class

class CBird
    sub Fly()
    end sub
end class

class CAnimal
    dim fish
    dim bird

    private sub class_initialize()
        set fish = new CFish
        set bird = new CBird
    end sub
   
    private sub class_terminate()
        set fish = nothing
        set bird = nothing
    end sub
end class

dim animal
set animal = new CAnimal
call animal.fish.Swim() '鱼游
call animal.bird.Fly() '鸟飞
set animal = nothing

相关文章