Go语言中文网 为您找到相关结果 1

golang 面向对象

method的语法如下: func (r ReceiverType) funcName(parameters) (results) 下面我们用最开始的例子用method来实现: package main import ( "fmt" "math" ) type Rectangle struct { width, height float64 } type Circle struct { radius float64 } func (r Rectangle) area() float64 { return r.width*r.height } func (c Circle) area() float64 { return c.radius * c.radius * math.Pi } func...阅读全文

博文 2014-10-04 19:26:12 huyuantai000