C++ typedef 重定义简单测试

#include <iostream>

using namespace std;
typedef int INT, * PINT;
typedef int* PINT32, INT32;

int main()
{
    int* p, a;

    a = 10;
    p = &a;
    cout << *p << endl;

    PINT p_t = p;
    *p_t = 11;
    cout << *p_t << endl;

    PINT32 p_t32 = p_t;
    *p_t32 = 12;
    cout << *p_t32 << endl;

    return 0;
}

输出:

10
11
12

可见:

  1. int* p, a; 这样定义aint类型,pint *类型。
  2. typedef int INT, * PINT; INT重定义是int类型,PINT重定义是int *类型。
  3. typedef int* PINT32, INT32; 和上面一样,前后位置并不影响。
posted @   double64  阅读(18)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示