搜书院首页

您好,欢迎光临搜书院,请登录|免费注册|客户服务|联系我们|网站导航
首页 教育科技 工业 C++编程风格
  • C++编程风格
  • C++编程风格
  • C++编程风格
  • C++编程风格
分享到
更多
送积分 0 查看大图
收藏商品 收藏人气:0

C++编程风格

搜书院价
¥ 34.37 ?钻石 VIP专享 折上9.5折
运费说明
¥0包邮
  • 普通地区满¥0元(含)包邮
  • 偏远地区满¥70元(含)包邮

[美]Tom Cargill
人民邮电出版社
出版时间
2013-01-01
I S B N
9787115295064
所属分类
工业 > 教育科技

商品详情

本书讲解了C++ 语言中较深层次的程序设计思想和使用方法,包含大量的软件工程概念和 设计模式,重点介绍大规模编程相关的内容,例如增加代码的可读性、可维护性、可扩展性以及 提高代码执行效率等的方法。本书的示例代码都是从实际程序中抽取出来的,作者通过对这些代 码进行分析,讲解了如何正确地编写代码以及避开一些常见的误区和陷阱,并提炼出了一些关于 程序设计风格和编码风格的规则。如果开发人员在编程时能够遵循这些规则,将有助于开发出更 好的C++ 程序。 本书描述平实,示例丰富,适合有一定编程经验的计算机程序设计与开发人员参考。目录 1 抽象 ·················································································································································1 1.1 编程风格示例:计算机的定价 ····················································································································1 1.2 找出共同的抽象 ··············································································································································5 1.3 类之间的区别 ···················································································································································9 1.4 属性与行为 ·······················································································································································9 1.5 再次引入继承 ·················································································································································12 1.6 去掉枚举 ·························································································································································13 小 结 ········································································································································································16 参考文献 ····································································································································································17 练 习 ········································································································································································17 2 一致性 ···········································································································································21 2.1 编程风格示例:string 类 ·····························································································································21 2.2 明确定义的状态 ············································································································································23 2.3 物理状态的一致性 ········································································································································24 2.4 类不变性 ·························································································································································25 2.5 动态内存的一致性 ········································································································································272 C++ 编程风格 2.6 动态内存的回收 ············································································································································28 2.7 编程风格示例:第二种方法 ·······················································································································29 小 结 ········································································································································································35 参考文献 ····································································································································································36 练 习 ········································································································································································36 3 不必要的继承 ·····························································································································41 3.1 编程风格示例:堆栈 ··································································································································41 3.2 继承作用域准则 ············································································································································44 3.3 继承关系 ·························································································································································46 3.4 封装 ··································································································································································50 3.5 接口与实现 ·····················································································································································52 3.6 模板 ··································································································································································56 小 结 ········································································································································································58 参考文献 ····································································································································································58 练 习 ········································································································································································58 4 虚函数 ···········································································································································59 4.1 编程风格示例:车辆与车库 ·······················································································································59 4.2 一致性 ······························································································································································63 4.3 基类的析构函数 ············································································································································65 4.4 继承 ··································································································································································66 4.5 耦合 ··································································································································································69 小 结 ········································································································································································75 参考文献 ····································································································································································75 练 习 ········································································································································································75 5 运算符的重载 ·····························································································································77 5.1 运算符重载的基本概念 ································································································································77 5.2 编程风格示例:FileArray 类 ·······················································································································82目录 3 5.3 对实现的继承 ·················································································································································89 5.4 程序设计中的权衡:重载运算符和成员函数 ·························································································94 小 结 ········································································································································································95 参考文献 ····································································································································································96 练 习 ········································································································································································96 6 包装 ···············································································································································97 6.1 一个用C 编写的库 ·······································································································································97 6.2 编程风格示例:用C++ 对dirent 进行包装 ···························································································98 6.3 多个Directory 对象 ···································································································································100 6.4 构造函数中的失败 ·····································································································································103 6.5 对失败状态的公有访问 ·····························································································································105 6.6 错误信息参数 ··············································································································································107 小 结 ······································································································································································111 参考文献 ··································································································································································111 练 习 ······································································································································································111 7 效率 ············································································································································113 7.1 编程风格示例:BigInt 类 ···························································································································114 7.2 BigInt 的使用 ···············································································································································120 7.3 动态字符串的长度 ·····································································································································121 7.4 动态字符串的数量 ·····································································································································123 7.5 客户代码 ······················································································································································127 7.6 改写BigInt ··················································································································································129 小 结 ·····································································································································································135 参考文献 ·································································································································································135 练 习 ·····································································································································································135 8 案例研究 ···································································································································137 8.1 编程风格示例:有限状态机 ····················································································································1374 C++ 编程风格 8.2 初始化 ···························································································································································142 8.3 耦合 ·······························································································································································150 8.4 内聚 ······························································································································································154 8.5 模块类与抽象数据类型 ·····························································································································157 8.6 属性与行为 ··················································································································································160 8.7 泛化 ·······························································································································································165 参考文献 ·································································································································································169 练 习 ·····································································································································································170 9 多重继承 ···································································································································171 9.1 多重继承中的二义性 ·································································································································171 9.2 有向无环继承图 ·········································································································································173 9.3 分析虚基类 ··················································································································································176 9.4 编程风格示例:Monitor 类 ·······················································································································183 9.5 编程风格示例:虚基类 ····························································································································187 9.6 多重协议继承 ··············································································································································192 小 结 ·····································································································································································195 参考文献 ·································································································································································195 练 习 ·····································································································································································195 10 摘要 ············································································································································199 第1 章:抽象 ························································································································································199 第2 章:一致性 ···················································································································································199 第3 章:不必要的继承 ······································································································································200 第4 章:虚函数 ···················································································································································200 第5 章:运算符的重载 ······································································································································201 第6 章:包装 ························································································································································201 第7 章:效率 ························································································································································201 第8 章:案例研究 ···············································································································································202 第9 章:多重继承 ···············································································································································202