zoukankan      html  css  js  c++  java
  • 数据结构之typedef

    typedef

    typedef的用法
    #include <stdio.h>
    
    typedef int ZHANGSHAN;
    //为int再重新多取一个名字,ZHANGSHAN等价于int
     
    
    typedef struct Student
    {
        int sid;
        char name[100];
        char sex;
    }ST;
    
    
    int main(void)
    {
        /*
        int i = 10;//等价于ZHANGSHN i=10;
        ZHANGSHAN j = 20;
        printf("%d
    ",j);
        */ 
        struct Student st;//等价于ST st; 
        struct Student *ps = &st;//等价于ST *ps = &st; 
        return 0;
    } 
    #include <stdio.h>
    
    
    typedef struct Student
    {
        int sid;
        char name[100];
        char sex;
    }* PST;//PST等价于struct Student * 
    
    
    int main(void)
    { 
        struct Student st;
        PST ps = &st;
        ps->sid = 99;
        printf("%d
    ",ps->sid);
        
        return 0;
    } 
    #include <stdio.h>
    
    
    typedef struct Student
    {
        int sid;
        char name[100];
        char sex;
    }* PST,ST;
    //等价于ST代表了struct Student,PST代表了struct Student * 
    
    
    int main(void)
    { 
        STU st;//struct Student st;
        PSTU ps = &st;//struct Student *ps = &st;
        ps->sid = 99;
        printf("%d
    ",ps->sid);
        
        return 0;
    } 
  • 相关阅读:
    .hpp文件
    最小高度的BST
    检查图中的有向路径
    c++ 对象内存布局详解
    链表求差
    offer--链表反转和从尾到头打印链表
    平衡二叉树的判断
    java 抽象类和接口
    原型模式--prototype
    装饰模式decorator
  • 原文地址:https://www.cnblogs.com/pig1314/p/8652975.html
Copyright © 2011-2022 走看看