package main import ( "fmt" ) // 캐릭터 일반 특성 type Human struct { name string level int } type Race struct { name string homeworld string } // 종족 특성 type Worgen struct { Human Race } type Pandaren struct { Human Race } // 인터페이스 메서드 type Instance interface { Hello() Dance() Attack(int) Information() } func (c Worgen) Hello() { fmt.Printf("%s : Hello everybody i'm worgen\n", c.Human.name) } func (c Pandaren) Hello() { fmt.Printf("%s : Good morning, Good afternoon, Gooe evening\n", c.Human.name) } func main() { Yundream := Worgen{Human{name: "yundream", level: 95}, Race{name: "Worgen", homeworld: "seoul"}} Yundream.Hello() Dragona := Pandaren{Human{name: "Dragona", level: 80}, Race{name: "Pandaren", homeworld: "NewYork"}} Dragona.Hello() }
Copyrights © - Joinc, All Rights Reserved. Inherited From - Yundream Rebranded By - Joonphil
소개
Interface
Empty Interface
Recent Posts
Archive Posts
Tags