在实现以下代码时,我遇到了一个错误:
package main
import (
"fmt"
)
type Struct struct {
a int
b int
}
func Modifier(ptr *Struct, ptrInt *int) int {
*ptr.a++
*ptr.b++
*ptrInt++
return *ptr.a + *ptr.b + *ptrInt
}
func main() {
structure := new(Struct)
i := 0
fmt.Println(Modifier(structure, &i))
}
这给我报了一个关于“无效指针ptr.a(类型为int)”的错误。同时,编译器为什么不会给我有关ptrInt的错误提示呢?提前致谢。