惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

博客园 - avisnet

枚举浏览器窗口 关闭弹出式IE浏览器窗口编程 iframe自适应高度 - avisnet - 博客园 实现集合类的帮助函数 FormView 在对话框里面使用ON_UPDATE_COMMAND_UI映射工具条 automation服务器不能创建对象 汇率 无题 [转]猪的爱情故事 在新窗口中打开网页,同时关闭原有窗口 删除文件至回收站而不是永久删除 低层键盘钩子 C++编译器默认声明的成员函数 使用SqlServer模式的会话状态管理 Session Data Is Lost When You Use ASP.NET InProc Session State Mode [转]LINK : warning LNK4089: all references to "xxx.dll" discarded by /OPT:REF VC++中消除警告 在 ASP.NET 中执行 URL 重写
const与typedef的中高级使用
avisnet · 2006-09-19 · via 博客园 - avisnet

摘自CSDN的一个贴子。

typedef int*   PINT;

const PINT p = NULL;

变量p是什么类型?

wanfustudio(雁南飞)

正确的解释是:int* const p
因为当用 typedef 定义了一种新的类型 PINT 后,const 修饰的对象就是PINT 而 PINT 本身是指针,于是const PINT 就是PINT 的值是常量
所以最后p被理解为 int 的const 的指针

zenny_chen (ACE Intercessor)

首先,const修饰词和其他类型修饰是并列的,即它们共同来修饰一个变量对象。

现讲一个简单的例子:

int const* p;

p的种属有两个,int 和 const*,因此p首先是个指针,不过该指针是const*类型的,即对p所指地址的内容进行const限定;然后它的取内容又是int类型的。

以上这种表示又可表示为:const int* p; 一样,const和int可以互换,但是不能和*进行交换,否则将是不同的语义。

int* const q;

q的种属有两种。首先它是int*类型,即指向int变量的指针,但是该指针同时又受到const的限制,使其值为const。

所以int const* 和int* const是不同的。

typedef int* PINT;

PINT为int*类型,该类型为一个整体。因此const PINT 同 PINT const的语义是完全一样的,都是PINT与const共同修饰变量,是该变量为用const来修饰int*指针变量。