接口方法.

下一个实现接口附加方法的方法是否正确?(getKey,getData)


type reader interface {

    getKey(ver uint) string

    getData() string

}


type location struct {

    reader

    fileLocation string

    err os.Error

}


func (self *location) getKey(ver uint) string {...}


func (self *location) getData() string {...}


func NewReader(fileLocation string) *location {

    _location := new(location)

    _location.fileLocation = fileLocation

    return _location

}


拉丁的传说
浏览 241回答 2
2回答

撒科打诨

您已经基本完成了。一旦给location的getKey和getData方法有效的主体,* location将实现阅读器接口。无需做任何其他事情。
打开App,查看更多内容
随时随地看视频慕课网APP