go语言第九课时

go语言第九课时

 

 1.接口多态

package main
import "fmt"
type Humon interface {
    syHi()
}
type Person struct {

}
type Student struct{

}
func (p *Person) sayHi(){
    fmt.Println("this is persion");
}
func ( stu *Student) sayHi(){
    fmt.Printf("this is student");
}
func main(){
    humn:=Person{};
    humn.sayHi();
}

 

上一篇:探探es 的class


下一篇:【webpack】 初次使用