zoukankan      html  css  js  c++  java
  • Go-struct

    struct(结构体)

    struct 类型由多个不同类型元素组合而成。struct 存储空间是连续,它按照字段声明时的顺序存储

    struct 形式

    • struct 类型字面量

      struct {
          FeildName FeildType
          FeildName FeildType
          FeildName FeildType
      }
      
    • 使用type 关键字声明的自定义struct类型

      type TypeName struct {
          FeildName FeildType
          FeildName FeildType
          FeildName FeildType
      }
      

    初始化

    type Person struct {
        Name string
        Age int
    }
    
    type Student struct {
        *Person
        Number int
    }
    
    p := &Person{
        Name:"biao",
        Age: 18,
    }
    
    s := Student {
        Person: p,
        Number: 100,
    }
    
  • 相关阅读:
    任务08——第一次半月学习总结
    任务5
    任务4
    任务3
    任务2
    mission 01
    HTML-CSS-JS Prettify报错Node.js was not found
    **1279
    UVa 10735
    UVa 1515
  • 原文地址:https://www.cnblogs.com/binliubiao/p/14502335.html
Copyright © 2011-2022 走看看