摘要:
package main import ( "fmt" ) type Dog struct { Name string Age int } func (d *Dog)bite() { fmt.Printf("%s要咬你了\n", d.Name) } type PoliceDog struct { //一行代码拥有父类的全部成员(属性+方法) Dog //扩展出新的属性 ... 阅读全文
摘要:
package main import "fmt" /* 面向过程编程:调度大量的变量、函数 面向对象编程(OOP=Object Oriented Programming) 对象=结构体/类的实例 对象.属性(面向过程中调度变量) 对象.方法(面向过程中调度汗水) */ type Dog struct { //结构体的属性 name string age int gender bool //结构体 阅读全文