zoukankan      html  css  js  c++  java
  • 4)给已有数据类型加别名

    数据类型:

        有 系统定义的

                int

                float

                double

                char

        还有自己定义的

          enem(枚举类型)

          struct  aa(这个aa就是你自己定义的新类型的名字)

    那个typedef  是给已有的数据类型起别名
          typedef   INT int ;          ------>就是用INT代替之前的int类型

          typedef  uint_32  unsigned int 32;

    typedef通常和结构体结合使用:

        正式的结构体定义样式:

                

    1 struct node
    2 {
    3 
    4     int a;
    5     float  b;
    6 
    7 }

        然后我在主函数中使用这个结构体:

    1 #include<stdio.h>
     2 struct node
     3 {
     4     int a;
     5     float b;
     6 
     7 }
     8 int main()
     9 {
    10     struct node AA;
    11     AA.a=10;
    12     AA.b=10.2;
    13     
    14 
    15 
    16 
    17 }

     但是  我用typedef给这个结构体起别名:

    1 typede  struct node
    2 {
    3     int a;
    4     float b;
    5 
    6 
    7 
    8 }bieming;
    9 //这个‘bieming'就是这个struct node的别名  以后我用’bieming‘就代表了  struct  node

    上面的代码等同于 : typedef  struct node  NODE;效果一样

        

  • 相关阅读:
    第二章整理
    汇编实验二
    汇编实验一
    第一章整理
    第一部分 | 第1章 —— Hello Cocos2d-x
    返回 *this 的成员函数以及 const重载
    C++中的const
    680. Valid Palindrome II
    字典树
    单调队列
  • 原文地址:https://www.cnblogs.com/xiaoyoucai/p/8011225.html
Copyright © 2011-2022 走看看