第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

不能調(diào)用非函數(shù)撤回(類型int)是什么意思?

不能調(diào)用非函數(shù)撤回(類型int)是什么意思?

Go
呼喚遠(yuǎn)方 2022-08-24 20:22:53
我創(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)。
查看完整描述

2 回答

?
海綿寶寶撒

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊

它的意思正是它所說的:你不能調(diào)用一個(gè)非函數(shù)。只能調(diào)用函數(shù)。

這里:

            deposit(deposit)

您正在嘗試調(diào)用 ,但類型為:depositdepositint

    var deposit int

此變量聲明在包范圍內(nèi)隱藏同名函數(shù)。deposit

若要解決您的問題,請(qǐng)為變量或函數(shù)使用其他名稱。


查看完整回答
反對(duì) 回復(fù) 2022-08-24
?
阿晨1998

TA貢獻(xiàn)2037條經(jīng)驗(yàn) 獲得超6個(gè)贊

變量名稱與函數(shù)名稱重疊。

嘗試更改其中之一


查看完整回答
反對(duì) 回復(fù) 2022-08-24
  • 2 回答
  • 0 關(guān)注
  • 123 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)