﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-编程人生</title><link>http://www.cppblog.com/lotusswan/</link><description>专注于编程，你定能成为高手。学习是一个长期的过程，坚持，坚持，再坚持！这才是成功的真谛。</description><language>zh-cn</language><lastBuildDate>Tue, 09 Jun 2026 02:54:10 GMT</lastBuildDate><pubDate>Tue, 09 Jun 2026 02:54:10 GMT</pubDate><ttl>60</ttl><item><title>C++ Gotchas读书笔记之一</title><link>http://www.cppblog.com/lotusswan/archive/2005/09/18/297.html</link><dc:creator>编程人生</dc:creator><author>编程人生</author><pubDate>Sun, 18 Sep 2005 08:47:00 GMT</pubDate><guid>http://www.cppblog.com/lotusswan/archive/2005/09/18/297.html</guid><wfw:comment>http://www.cppblog.com/lotusswan/comments/297.html</wfw:comment><comments>http://www.cppblog.com/lotusswan/archive/2005/09/18/297.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lotusswan/comments/commentRss/297.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lotusswan/services/trackbacks/297.html</trackback:ping><description><![CDATA[<FONT size=2>C++ Gotchas 1：关于注释<BR>1.鼓励注释，但应该尽可能减少注释。<BR>&nbsp;&nbsp;&nbsp;&nbsp; 注释可能使维护人员分心；注释的维护很难做，甚至没有人愿意做维护注释的工作。<BR>2.减少注释的方法<BR>&nbsp;&nbsp;&nbsp;&nbsp; 使用有意义的名称来定义函数、变量、参数、类；使用标准组件或算法，尽量避免闭门造车。<BR><BR>C++ Gotchas 2：魔数<BR>1.魔数：在上下文中本来应该使用常量变量的原始数字值。<BR>2.魔数缺点：数字没有任何意义；数字会存在类型、精度等问题。<BR>3.使用有意义的名称（如枚举、常量变量）代替数字。<BR><BR>C++ Gotchas3:全局变量<BR>1.全局变量阻碍重用<BR>&nbsp;&nbsp;&nbsp;&nbsp; 使用了全局变量的代码的重用性被阻碍了。<BR>2.全局变量加大维护难度<BR>3.取代全局变量<BR>3.参考<BR>《C++ Coding Standards: 101 Rules, Guidelines, and Best Practices》chp10、18<BR>《<SPAN class=docEmphasis>Code Complete</SPAN>》§5.1-4, §10.1<BR>《<SPAN class=docEmphasis>The C++ Programming Language</SPAN>》§4.9.4, §6.3<BR>4.这一部分不是十分了解，还需深入。</FONT><img src ="http://www.cppblog.com/lotusswan/aggbug/297.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lotusswan/" target="_blank">编程人生</a> 2005-09-18 16:47 <a href="http://www.cppblog.com/lotusswan/archive/2005/09/18/297.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>