ARTS-S golang定义类

package main

import "fmt"

type Student struct {
	Num int64
	Name string
}

func(s *Student) setName(name string) {
	s.Name = name
}

func(s *Student) setNum(num int64) {
	s.Num = num
}

func(s *Student) getName() string {
	return s.Name
}

func(s *Student) getNum() int64 {
	return s.Num
}

func main() {
	s := Student{}
	s.setName("张三")
	s.setNum(123)
	fmt.Println(s.getName())
	fmt.Println(s.getNum())
}


posted on 2019-02-13 08:11  荷楠仁  阅读(136)  评论(0编辑  收藏  举报

导航