当前位置:网站首页>Go language self-study series | golang nested structure
Go language self-study series | golang nested structure
2022-04-23 08:50:00 【COCOgsta】
Video source :B standing 《golang Introduction to project practice [2021 newest Go Language course , There is no nonsense , Dry only ! Ongoing update ...]》
Organize the teacher's course content and test notes while studying , And share it with you , Infringement is deleted , Thank you for your support !
Attach summary sticker :Go Language self-study series | Summary _COCOgsta The blog of -CSDN Blog
go Language has no idea of object-oriented programming , There is no inheritance , However, this effect can be achieved through structure nesting .
The following is an example to demonstrate how to realize structure nesting , If there is a person Person Structure , This man also has a pet Dog Structure
So let's see :
Dog Structure
type Dog struct {
name string
color string
age int
}
Person Structure
type person struct {
dog Dog
name string
age int
}
Visit them
package main
import "fmt"
type Dog struct {
name string
color string
age int
}
type person struct {
dog Dog
name string
age int
}
func main() {
var tom person
tom.dog.name = " tearful "
tom.dog.color = " Black and white flower "
tom.dog.age = 2
tom.name = "tom"
tom.age = 20
fmt.Printf("tom: %v\n", tom)
}
Running results
[Running] go run "d:\SynologyDrive\ software development \go\golang Introduction to project practice \goproject\360duote.com\pro01\test.go"
tom: {
{ tearful Black and white flower 2} tom 20}
版权声明
本文为[COCOgsta]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230822135725.html
边栏推荐
- Use of Arthas in JVM tools
- 增强现实技术是什么?能用在哪些地方?
- Failed to prepare device for development
- PLC point table (register address and point table definition) cracking detection scheme -- convenient for industrial Internet data acquisition
- 关于cin,scanf和getline,getchar,cin.getline的混合使用
- Introduction to matlab
- HAL库的RCC简介
- Valgrind and kcache grind use run analysis
- 洋桃电子STM32物联网入门30步笔记三、新建CubeIDE工程和设置讲解
- Talent Plan 学习营初体验:交流+坚持 开源协作课程学习的不二路径
猜你喜欢

共享办公室,提升入驻体验

资源打包关系依赖树

Yangtao electronic STM32 Internet of things entry 30 step notes II. Cube ide download, installation, sinicization and setting

深度学习框架中的自动微分及高阶导数

The K neighbors of each sample are obtained by packet switching

请提前布局 Star Trek突破链游全新玩法,市场热度持续高涨

Consensus Token:web3. 0 super entrance of ecological flow

经典题目刷一刷

Chris LATTNER, father of llvm: the golden age of compilers

Notes on 30 steps of introduction to the Internet of things of yangtao electronics STM32 III. cubemx graphical programming and setting the IO port on the development board
随机推荐
LeetCode_DFS_中等_1254. 统计封闭岛屿的数目
Judgment on heap (25 points) two insertion methods
2022-04-22 openebs cloud native storage
php基于哈希算法出现的强弱比较漏洞
政务中台研究目的建设目标,建设意义,技术创新点,技术效果
企业微信应用授权/静默登录
Latex mathematical formula
Type anonyme (Principes fondamentaux du Guide c)
Go语言自学系列 | golang方法
【原创】使用System.Text.Json对Json字符串进行格式化
JVM工具之Arthas使用
Go语言自学系列 | golang结构体指针
Experimental report on analysis of overflow vulnerability of assembly language and reverse engineering stack
valgrind和kcachegrind使用运行分析
【IndexOf】【lastIndexOf】【split】【substring】用法详解
深度学习框架中的自动微分及高阶导数
2021 Li Hongyi's adaptive learning rate of machine learning
关于堆的判断 (25 分) 两种插入方式
Illegal character in scheme name at index 0:
L2-024 tribe (25 points) (and check the collection)