c++ style
来源:互联网 发布:数据采集系统方案 编辑:程序博客网 时间:2024/05/16 08:18
1.When defining a function, parameter order is: inputs, then outputs. 参数的顺序:输入在前,输出在后
2.Use standard order for readability and to avoid hidden dependencies:C library, C++ library, other libraries' .h, your project's .h. 包含文件的顺寻:c库,c++库、其它库、自己的h文件
3.Prefer nonmember functions within a namespace or static member functions to global functions; use completely global functions rarely. 命名空间中定义非成员函数或者静态成员函数,尽量不使用全局函数。
4.Static or global variables of class type are forbidden: they cause hard-to-find bugs due to indeterminate order of construction and destruction.不要使用静态或者全局类:因为其无法确定的构建、销毁顺序。
5.In general, constructors should merely set member variables to their initial values. Any complex initialization should go in an explicit Init() method.初始化不要放在构建函数中,要放在init函数中。
6.Use the C++ keyword explicit for constructors with one argument.Copy Constructors .Provide a copy constructor and assignment operator only when necessary. Otherwise, disable them with DISALLOW_COPY_AND_ASSIGN. 显示声明构造函数;拷贝构造函数和赋值操作符,如果不许要则禁止。
7.Use a struct only for passive objects that carry data; everything else is a class. 搭载data的时候使用struct,其他使用class
8.Composition is often more appropriate than inheritance. When using inheritance, make it public.继承不如包含,继承的时候使用public
9.Make data members private, and provide access to them through accessor functions as needed (for technical reasons, we allow data members of a test fixture class to be protected when using Google Test). Typically a variable would be called foo_ and the accessor function foo(). You may also want a mutator function set_foo(). Exception: static const data members (typically called kFoo) need not be private.
10.Use the specified order of declarations within a class: public:before private:, methods before data members (variables), etc. public在前,private在后,方法在前,数据成员(变量)在后
11.Use 0 for integers, 0.0 for reals, NULL for pointers, and '\0' for chars.
12.Use sizeof(varname) instead of sizeof(type) whenever possible.
- C style字符串
- Objective-c Code Style
- comment style in C
- C style字符串
- C style字符串
- objective-c code style
- Google-C++-style-headerfile
- c style covert and c++ style
- C & C++ Programming Style Guidlines
- C#-continuation-passing style(CPS)
- Objective-C Coding Style Guidelines
- c-style string 的区别
- reverse a C-Style String
- Google Objective-C Style Guide
- emacs使用google-c-style
- Objective-c coding style guide
- Item2: Prefer C++-style casts
- Objective-C Coding Style Guidelines
- 十个Android开发案例打包下载
- GetLastError()返回值的意义
- 《Java Concurrency in Practice》 学习笔记--第二章:线程安全
- 拷贝构造函数(浅拷贝和深拷贝)
- IPhone学习笔记三-----图像视图和文本字段
- c++ style
- Delphi 变体类型(Variant)的介绍(流与变体类型的相互转换、变体类型常用的函数)
- MyEclipse安装时出的小错误
- 关于“打开项目**时发生问题,尝试退出并重新启动应用程序。如果问题仍然存在,则可能是由于正在使用不支持的项目版本,或者项目文件可能损坏”的问题的解决办法。
- 内存区域,堆栈区别
- 认识Linux版本
- 协同通信
- 什么是Android NDK 什么情况下使用Android NDK
- CSS常用命名规范及写法详解