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

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Last Watchdog
The Last Watchdog
AI
AI
Recent Announcements
Recent Announcements
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
J
Java Code Geeks
TaoSecurity Blog
TaoSecurity Blog
L
LangChain Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Microsoft Security Blog
Microsoft Security Blog
量子位
T
Threatpost
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - Franky
博客园 - 聂微东
L
LINUX DO - 最新话题
Security Archives - TechRepublic
Security Archives - TechRepublic
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
C
Check Point Blog
宝玉的分享
宝玉的分享
G
Google Developers Blog
Spread Privacy
Spread Privacy
Cloudbric
Cloudbric
SecWiki News
SecWiki News
有赞技术团队
有赞技术团队
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
美团技术团队
V
Vulnerabilities – Threatpost
Cyberwarzone
Cyberwarzone
A
Arctic Wolf
P
Privacy & Cybersecurity Law Blog
P
Palo Alto Networks Blog
H
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
About on SuperTechFans
N
Netflix TechBlog - Medium
罗磊的独立博客
月光博客
月光博客

博客园 - 空气

没有不可能的事情 迅景如梭,旧游似梦,烟水程何限 [转]一些web开发中常用的、做成cs文件的js代码 数类 MBTI职业性格测试 Which Programming Lanuguage Are You? 如何解释内存中的内容 好久没来了。。。 第七章: 封装 - 空气 - 博客园 C/C++中的内存管理 经典正则表达式 二叉树的显示 软件工厂的考试题目程序 第六章: 字符串 测试-通过Word 2007发布Blog 第五章: 数组 第四章: 从 autoboxing 和 unboxing 认识对象 第三章: 语法入门 0. 序
1. 让自己习惯C++
空气 · 2006-12-01 · via 博客园 - 空气

条款01: C++为一个语言联邦:

包含四个部分

    C
    OOC++
C with Classes.
    Template C++.
即泛型编程
    STL

C++高效编程守则视状况而变化,取决于你使用C++的哪一部分.

条款02: 尽量以 const, enum, inline 替换 #define

即以编译器换预处理.

对于单纯常量,最好以const对象或enums替换#define

对于形似函数的宏,最好用inline函数来替换,必要时应该使用 template

条款03: 尽可能使用 const

将某些东西声明为const可帮助编译器侦测出错误用法. const可被施加于任何作用域内的对象,函数参数,函数返回值,成员函数本体.

STL const_iterator 不可改变他所指向的值,可以改变指针自身.

Const std::vector<int>::iterator 则相反

令函数返回一个常量值,往往可以降低因客户错误而造成的意外.

两个成员函数如果只是常量性不同(即一个有const,一个没有const), 可以被重载.

Mutable关键字可以释放掉non-static 成员变量的const约束

constnon-const成员函数有着实质等价的实现时,non-const版本调用const版本可避免代码重复

条款04: 确定对象被使用前已先被初始化

对内置型对象进行手工初始化.

对于内置类型以为的东西,确保每一个构造函数都将对象的每一个成员初始化.并且应该使用初始化列表而不是在构造函数本体内使用赋值操作.

对于多个编译单元的 non-local static 对象,应以 local static 对象替换 non-local static 对象