博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
把《Effective C++》读薄
阅读量:6620 次
发布时间:2019-06-25

本文共 1687 字,大约阅读时间需要 5 分钟。

这本书很早就打算看了,但是一直没有开始。我觉得这本书其实只需要有一定C++经验,越早接触越好!

1

  • view c++ as a federation of languages
    应该看作C、STL、Templete、面对对象四个部分
  • prefer consts,enum,inline to #define
  • use const whenever possible
  • make sure the objects are initialized before they are used;
//这些都是初始化int x=0;const char* a="abcde";double d;cin>>d;Shit(string name,string address):name(name),address(address){}//Shit(stirng name,string address){this.name=name,this.address=address;}会先赋初值

2 Constructor,Destruction,and Assignment Operators

  • know what function C++ silently write and calls
  • Explicitly disallow the use of complier-generated functions you do not want
  • Declare destructors virtual in polymophic base classe
  • Prevent exception from leaving destructors
  • Never call virtual function during construction or destruction
  • Have assignment operator return a reference to *this
  • Handle assignment to self in operator =

3 Resource Management

  • use object to manage resources
  • think carefully about copying behavior in resources manage classed
  • provide access to raw resources on resource-managing classedd
  • use the same form in corresponding use of new and delete
  • store new objects in smart pointers in standalone statements

4 Design and Declarations

  • make interfaces easy to use correctly and hard to use incorrectly
  • treat class design as type design
  • prefer pass-by-reference-to-const to pass-by-value
  • don’t try to return a reference when you must return an object
  • declare date member private
  • prefer non-member non-friend functions to member functions
  • declare non-member functions when type conversions should apply to all parameters
  • consider support for a non-throwing swap

版权声明:本文为博主原创文章,转载请标明出处。

转载于:https://www.cnblogs.com/fridge/p/4861899.html

你可能感兴趣的文章
Linux下gdb的安装及使用入门
查看>>
Java 程序执行过程的内存分析
查看>>
灾难恢复-boot分区的恢复方法
查看>>
小游戏-猜数字
查看>>
深度学习到顶,AI寒冬将至!
查看>>
【投资】欧盟区块链创业公司投资超500万欧元
查看>>
优傲机器人:人机协作机器人助推电子制造业智慧升级
查看>>
IBM利用“沃森”超级电脑帮助员工对抗癌症
查看>>
「镁客·请讲」珍为科技周朔鹏:打造科技产品传播平台,对接智能制造产业上下游...
查看>>
使用NHibernate作为ORM容易碰到的问题
查看>>
服务器集中检测Cacti
查看>>
快速构建Windows 8风格应用34-构建Toast通知
查看>>
WCF简单教程(6) 单向与双向通讯
查看>>
Linux下多线程编程简介(一)
查看>>
RHEL6入门系列之八,常用命令1
查看>>
安全防范之彻底击破恶意网页
查看>>
安全防护 守好家门 也谈端口的开关
查看>>
浅谈ADC产品32位和64位之区别
查看>>
IBM Call Home Function
查看>>
Linux系统自带的密码生成器——mkpasswd
查看>>