提交 a61b6fff 编写于 作者: WebCoderT's avatar WebCoderT 🚴🏼

method.go is change

上级 53588c62
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -3,12 +3,18 @@ package main ...@@ -3,12 +3,18 @@ package main
import "fmt" import "fmt"
type memployee struct { type memployee struct {
name string name string
salary int salary int
} }
type myInt int
func (a myInt) add(b myInt) myInt {
return a + b
}
func (emp memployee) show_name() { func (emp memployee) show_name() {
fmt.Printf("name is %s",emp.name) fmt.Printf("name is %s", emp.name)
} }
func (emp memployee) change_name(new_name string) { func (emp memployee) change_name(new_name string) {
...@@ -23,4 +29,8 @@ func main() { ...@@ -23,4 +29,8 @@ func main() {
} }
emp1.show_name() emp1.show_name()
emp1.change_name("iii") emp1.change_name("iii")
}
\ No newline at end of file x := myInt(5)
fmt.Println(x.add(9))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册