当前位置:网站首页>Go language learning notes - structure | go language from scratch
Go language learning notes - structure | go language from scratch
2022-04-23 09:18:00 【Swordsman a Liang_ ALiang】
Learning notes , Where is where .
Structure is a little similar to the concept of class , Different data types can be defined for different items in the structure . More like the concept of data set .
The sample code is as follows
package main
import "fmt"
type Student struct {
name string
age int
gender string
}
func test_type(stu, stu1 Student) {
fmt.Printf("%s,%s\n", stu.name, stu1.name)
fmt.Printf("age + age = %d\n", stu.age+stu.age)
}
func test_type1(stu, stu1 *Student) {
fmt.Printf("%s,%s\n", stu.name, stu1.name)
fmt.Printf("age + age = %d\n", stu.age+stu.age)
}
func main() {
fmt.Println(Student{" Xiao Huang ",
19, " male "})
fmt.Println(Student{name: " Xiao Huang ", age: 19})
fmt.Println("---------------------------------")
var stu Student = Student{" Xiao Huang ", 19, " male "}
var stu1 Student = Student{" Xiaohong ", 18, " Woman "}
test_type(stu, stu1)
test_type1(&stu, &stu1)
}
Execution results
{ Xiao Huang 19 male }
{ Xiao Huang 19 }
---------------------------------
Xiao Huang , Xiaohong
age + age = 38
Xiao Huang , Xiaohong
age + age = 38
Summary
Still can't completely and java Analogy of classes .
版权声明
本文为[Swordsman a Liang_ ALiang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230633437859.html
边栏推荐
- Kettle experiment
- 小程序报错:Cannot read property 'currentTarget' of undefined
- Production practice elk
- LeetCode_DFS_中等_1254. 统计封闭岛屿的数目
- SAP 101K 411k inventory change
- kettle实验
- Image processing in opencv -- Introduction to contour + contour features
- Applet error: should have URL attribute when using navigateto, redirectto or switchtab
- 搞不懂时间、时间戳、时区,快来看这篇
- 爬虫使用xpath解析时返回为空,获取不到相应的元素的原因和解决办法
猜你喜欢
Installation of data cleaning ETL tool kettle
2021 Li Hongyi's adaptive learning rate of machine learning
Valgrind and kcache grind use run analysis
Cross domain configuration error: when allowcredentials is true, allowedorigins cannot contain the special value "*“
Harbor enterprise image management system
ATSS(CVPR2020)
Write down the post order traversal of the ~ binary tree
nn. Explanation of module class
Bk3633 specification
Matlab draw five-star red flag
随机推荐
员工试用期转正申请书(泸州老窖)
Strength comparison vulnerability of PHP based on hash algorithm
调包求得每个样本的k个邻居
On array replication
数据清洗 ETL 工具Kettle的安装
Find the sum of simple types of matrices
501. Mode in binary search tree
Kettle experiment
Kettle实验 (三)
I don't understand time, timestamp and time zone. Look at this article
js 原型链的深入
ASUS laptop can't read USB and surf the Internet after reinstalling the system
AQS & reentrantlock implementation principle
DJ music management software pioneer DJ rekordbox
112. Path sum
Kettle experiment conversion case
Wechat: get the owner of a single tag
小程序报错:Cannot read property 'currentTarget' of undefined
EmuElec 编译总结
Write down the post order traversal of the ~ binary tree