目录
1 概览................................................................................................................................................... 1 1.1 原则和主旨.................................................................................................................................... 1 1.2 术语................................................................................................................................................ 2 2 通用编程规范.................................................................................................................................. 3 2.1 明确和一致.................................................................................................................................... 3 2.2 格式和风格.................................................................................................................................... 3 2.3 库的使用........................................................................................................................................ 5 2.4 全局变量........................................................................................................................................ 5 2.5 变量的声明和初始化..................................................................................................................... 6 2.6 函数的声明和调用......................................................................................................................... 7 2.7 语句................................................................................................................................................ 8 2.8 枚举................................................................................................................................................ 9 2.9 空格.............................................................................................................................................. 14 2.10 大括号.......................................................................................................................................... 15 2.11 注释.............................................................................................................................................. 17 2.12 代码块.......................................................................................................................................... 26 3 C++ 编程规范................................................................................................................................. 27 3.1 编译器选项................................................................................................................................... 27 3.2 文件和结构................................................................................................................................... 29 3.3 命名规范...................................................................................................................................... 30 3.4 指针.............................................................................................................................................. 34 3.5 常量.............................................................................................................................................. 34 3.6 类型转换...................................................................................................................................... 35 3.7 Sizeof............................................................................................................................................ 36 3.8 字符串.......................................................................................................................................... 37 3.9 数组.............................................................................................................................................. 38 3.10 宏.................................................................................................................................................. 39 3.11 函数.............................................................................................................................................. 40 3.12 结构体.......................................................................................................................................... 43 3.13 类.................................................................................................................................................. 44 3.14 COM.............................................................................................................................................. 50 3.15 动态分配...................................................................................................................................... 51 3.16 错误和异常................................................................................................................................... 52 3.17 资源清理...................................................................................................................................... 55 3.18 控制流.......................................................................................................................................... 58 4 .NET 编码规范............................................................................................................................... 61 4.1 类库开发设计规范....................................................................................................................... 61 4.2 文件和结构................................................................................................................................... 61 4.3 程序集属性................................................................................................................................... 61 4.4 命名规范...................................................................................................................................... 61 4.5 常量.............................................................................................................................................. 65 4.6 字符串.......................................................................................................................................... 65 4.7 数组和集合................................................................................................................................... 67 4.8 结构体.......................................................................................................................................... 69 4.9 类.................................................................................................................................................. 70 4.10 命名空间...................................................................................................................................... 74 4.11 错误和异常................................................................................................................................... 74 4.12 资源清理...................................................................................................................................... 77 4.13 交互操作...................................................................................................................................... 90
|