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

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - vcfly

戏剧性的中超2008, 戏剧性的最后四轮,戏剧性的过程, 如我所愿的结果 Gmail换界面了 Hold fast and let go ... 一道逻辑推理题: 猜生日 数组 循环位移 或 循环移动 (左移 或 右移) K位 刚听了许巍的<<风行>>和<<故事>>, 软件开发之胡言乱语5-团队协作 软件开发之胡言乱语4: 实践与软件开发 Google is turning 10 软件开发之胡言乱语3-代码质量 软件开发之胡言乱语2 软件开发之胡言乱语1 决定个人软件质量高低的几个因素 调查: 哪些windows应用软件是用C#写的?哪些网站是用Asp.net写的? ZZ:<<给新人程序员的八点建议>> 越来越看不懂<<程序员>>... 写程序就像是上厕所 谁说Gmail不需要删邮件?! 单位门口的门卫
理解性记忆const修饰普通变量和指针的新思路 - vcfly - 博客园
vcfly · 2008-12-27 · via 博客园 - vcfly

看了"C++中const用法总结 ", 谈点新思路. 关于理解下面语句中的const:

A. const char *pContent;
B. char * const pContent;
C. char const *pContent;
D. const char* const pContent;

标准的助记方法是:

沿着*号划一条线,
如果const位于*的左侧,则const就是用来修饰指针所指向的变量,即指针指向为常量;
如果const位于*的右侧,const就是修饰指针本身,即指针本身是常量。

当然,这也是c++之父的著作<<C++程序设计语言>>里的方法.


我的想法是: const用来修饰的是其右侧第一个变量或类型的常量属性.

对于A, const修饰的是char, char是类型, 所对应的变量是 *pContent; 所以A中const表示指向的内容不变

对于B, const修饰的是pContent, 即表示char*型的指针pContent不变.

对于C, const修饰的是*pContent,即同A.

对于D, 第一个const修饰的是char, 同A, 第二个const修饰的是pContent,同B.