我創(chuàng)建了這個(gè)程序package mainimport "fmt"var bankAccount = 12342func withdraw(withdrawAmnt int) int { //withdraw function, return int bankAccount -= withdrawAmnt if bankAccount < 0 { bankAccount += withdrawAmnt //bankaccount cannot go negative return 1 } else { return 0 }}func deposit(depositAmnt int) { bankAccount += depositAmnt}func main() { var choice int var withdraw int var deposit int fmt.Printf("%d \n 1. withdraw \n 2. deposit \n 3. exit") fmt.Scanln(&choice) switch choice { case 1: fmt.Scanln(&withdraw) if withdraw(withdraw) != 0 { fmt.Println("Not succesful: not enough money (you're broke)") } case 2: fmt.Scanln(&deposit) deposit(deposit) case 3: os.Exit() }}我不斷得到這個(gè)錯(cuò)誤:不能調(diào)用非函數(shù)存款(類型int),也不能調(diào)用非功能存款(類型int)。
不能調(diào)用非函數(shù)撤回(類型int)是什么意思?
呼喚遠(yuǎn)方
2022-08-24 20:22:53