当前位置:网站首页>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
边栏推荐
- The most concerned occupations after 00: civil servants ranked second. What was the first?
- Enterprise wechat application authorization / silent login
- [C language] document operation
- 基于ThinkPHP5版本TRC20-资金归集解决方案
- Bk3633 specification
- MYCAT configuration
- Kettle experiment conversion case
- A must see wechat applet development guide 1 - basic knowledge
- 【读书笔记】《Verilog数字系统设计教程》 第5章 条件语句、循环语句和块语句(附思考题答案)
- Harbor enterprise image management system
猜你喜欢

501. Mode in binary search tree

Emuelec compilation summary

Enterprise wechat application authorization / silent login

爬虫使用xpath解析时返回为空,获取不到相应的元素的原因和解决办法

2021 Li Hongyi's adaptive learning rate of machine learning

Common errors of VMware building es8

MySQL小练习(仅适合初学者,非初学者勿进)
![[SQL Server fast track] view and cursor of database](/img/2c/8edd92ecef11932c982db56af76c3f.png)
[SQL Server fast track] view and cursor of database

Using JS to realize a thousandth bit

Strength comparison vulnerability of PHP based on hash algorithm
随机推荐
Number theory to find the sum of factors of a ^ B (A and B are 1e12 levels)
The most concerned occupations after 00: civil servants ranked second. What was the first?
三、6【Verilog HDL】基础知识之门级建模
112. 路径总和
小女孩行走
Notes on xctf questions
Machine learning (VI) -- Bayesian classifier
How to render web pages
Give the method of instantiating the object to the new object
2D 01 Backpack
tsdf +mvs
Employee probation application (Luzhou Laojiao)
Kettle experiment (III)
653. Sum of two IV - input BST
A must see wechat applet development guide 1 - basic knowledge
SAP 101K 411k inventory change
Kettle实验 转换案例
Little girl walking
Kettle实验
Distributed message oriented middleware framework selection - Digital Architecture Design (7)