> I think I finally found the easiest way to make virtual function works, 
> based on Nick Patavalis code and Tahir Hashmi's idea:
>
>
> func (a Animal) Output(s Speaker) {
> // Complicated stuff that must not be re-implemented
> fmt.Print("I am a ", s.IsA(),
> ". My name is ", a.Name,
> ", aged ", a.Age,
> ", it is ", a.IsMale,
> " I am male.\n ")
> s.Speak()
> }
>
>
>
> https://github.com/suntong/lang/blob/master/lang/Go/src/oo/Polymorphism-AnimalVF2.go
>
>
This is merely resorting to a shared function. This does not really cover 
overwriting in the OO sense. The article I mentioned shows how to do this: 
http://objectscape.blogspot.de/2013/09/inner-pattern-to-mimic-method.html 


Cheers, Haddock
 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to