typedef 指针定义【使用复杂指针类型时,可以用 typedef 关键字来取别名】

typedef 指针定义

#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef unsigned int UInt32; //  1. 简化类型
typedef float Real;          //  2. 定义平台无关的类型
typedef void(*PFUN)();         //  3. 定义了一个函数指针类型,返回值为 void,参数没有
typedef int IntArray[10];         //  4. 定义数组类型

void foo()
{
    printf("foo\n");
}

int main()
{
    UInt32 age = 18;
    printf("age:%u\n", age);
    Real score = 59.5;
    //  3. 函数指针
    PFUN fun = foo;
    fun();
    //  4. 定义数组类型
    IntArray arr;
    return 0;
}
posted @ 2024-08-25 10:45  爱新觉罗LQ  阅读(0)  评论(0编辑  收藏  举报