zoukankan      html  css  js  c++  java
  • 【转载】C++中结构体的声明和定义

    http://blog.csdn.net/whuslei/article/details/5665289

    //定义一个结构体,类型为struct Student
    struct  Student     
    {
        string name;
        double eng;
        double ch;
    }; 
     
    //定义了一个结构体,类型为struct Student;且定义了一个结构体实例,名叫Stu
    10  struct  Student    
    11  {
    12      string name;
    13      double eng;
    14      double ch;
    15  }Stu; 
    16   
    17  //定义了无名的结构体,且定义了一个结构体实例,名叫Stu
    18  struct 
    19  {
    20      string name;
    21      double eng;
    22      double ch;
    23  }Stu; 
    24   
    25  //重定义结构体,类型为struct Student 或者是Stu
    26  typedef struct  Student  
    27  {
    28      string name;
    29      double eng;
    30      double ch;
    31  }Stu; 
    32   
    33  //重定义结构体,类型为Stu
    34  typedef struct  
    35  {
    36      string name;
    37      double eng;
    38      double ch;
    39  }Stu;
    40   

    如果用typedef则,Stu stu; 
    否则,struct Student stu; 

  • 相关阅读:
    nginx公网IP无法访问浏览器
    Internet接入方式
    Adobe Photoshop Lightroom 5.3和序列号
    getopt
    printf
    scanf
    cycling -avoid the vicious cycle
    ACE handle_timeout 事件重入
    Linux查看程序端口占用
    The GNU C Library
  • 原文地址:https://www.cnblogs.com/iack/p/3817554.html
Copyright © 2011-2022 走看看