迷路的龙猫

Hacking the interesting world!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  C++议题

记录关于C++使用中所见所闻。
摘要:Things to Rember:1.Manually initialize objects of built-in type, because C++ only sometimes initializes them itself.为内置型对象进行手工初始化,因为C++不保证初始化它们。2.In a constructor, prefer use of the member initialization list to assignment inside the body ofthe constructor. List data members in the initialization li 阅读全文
posted @ 2014-04-08 21:42 迷路的龙猫 阅读(147) 评论(0) 推荐(0)

摘要:Things to Rember1.Declaring something const helps compilers detect usage errors. const can be applied to objects atany scope, to function parameters and return types, and to member functions as a whole.将某些东西声明为const可帮助编译器侦测出错误用法。const可被施加于任何作用域内的对象、函数参数、函数返回类型、成员函数本体。2.Compilers enforce bitwise cons 阅读全文
posted @ 2014-04-06 21:26 迷路的龙猫 阅读(181) 评论(0) 推荐(0)

摘要:英文标题(Prefer consts, enums, and inlines to #defines)理由:①使用宏定义常量的过程中,出错的时候难以调试,宏的常量在编译时不进入符号表。②使用宏定义的函数功能,极容易出现错误的期待结果。Things to remember:1.for simple constants, prefer const objects or enums to #define.对于一般的常量,尽量使用const对象或者枚举,而不用宏。2.For function-like macros, prefer inline functions to #define.对于类似函数的 阅读全文
posted @ 2014-03-27 22:22 迷路的龙猫 阅读(248) 评论(0) 推荐(0)

摘要:标题英文(View C++ as a federation)认识C++,你需要认识到语言中包含的4个部分:1.CC++中面向过程的部分。2.面向对象C++类、封装、继承、多态、虚函数。3.模板C++泛型编程(包括template metaprogramming)4.STL容器、迭代器、算法、function object.Things to Remember:Rules for effective C++ programming vary,depending on the part of C++ you are using.----------------------------------- 阅读全文
posted @ 2014-03-21 17:11 迷路的龙猫 阅读(214) 评论(0) 推荐(0)

摘要:在书中看到一段代码,使用到了std::setw()这个方法,记录一下用法。这个方法用来设定输入或者输出流中的缓冲区的宽度(set field width).这个方法定义在头文件中。可用来对齐输出的文本流或者截取部分数据。示例1:参考自cpluspluswww.cplusplus.com/reference/iomanip/setw/// setw example#include // std::cout, std::endl#include // std::setwint main () { std::cout 2 #include 3 #include 4 ... 阅读全文
posted @ 2014-03-02 20:18 迷路的龙猫 阅读(3175) 评论(0) 推荐(0)