2 回答

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超4個(gè)贊
我真的不知道你在這里真正想做什么,但是代碼有幾個(gè)問題
a 和 b 未定義,我將它們添加到 complex 以使其編譯
a <= r <= b 在 go 中無效,更改為
你有一個(gè)主要的,所以我假設(shè)你的意思是這是一個(gè)可運(yùn)行的應(yīng)用程序。包需要被稱為“main”才能直接運(yùn)行。
可能不是你想要的,但它現(xiàn)在編譯并運(yùn)行(但不做任何事情,因?yàn)?main 是空的)
package main
//import "fmt"
type Intervall interface {
contains(r float64) bool // if r is in x, then true
average(Y Intervall) (Intervall, error)
String() string //cast interval"[a,b]" to [a,b]
completecontains(Y Intervall) bool //if y is completely in x, give true
New(a, b float64) Intervall
}
type Complex struct {
first int
a float64
b float64
}
func (c Complex) contains(r float64) bool {
if c.a <= r && r <= c.b {
return true
} else {
return false
}
}
func (c Complex) String() string {
return "a"
}
func (c Complex) length() float64 {
return 2.3
}
func main() {
}
- 2 回答
- 0 關(guān)注
- 206 瀏覽
添加回答
舉報(bào)