2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。 package main import ( “fmt“ ) type integer in

2023-07-29,,

2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。

package main

import (
"fmt"
) type integer int func (i integer) String() string {
return "hello"
} func main() {
fmt.Println(integer(5))
}

答案2022-07-26:

答案选B。调用的是interger的String方法,所以是hello。不要被integer是整型所迷惑。

2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。 package main import ( “fmt“ ) type integer in的相关教程结束。

《2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。 package main import ( “fmt“ ) type integer in.doc》

下载本文的Word格式文档,以方便收藏与打印。