• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
sfesly
博客园 首页 新随笔 联系 订阅 订阅 管理

2016年2月28日

C++11 auto_ptr 的问题
摘要: auto_ptr作为最早的智能指针,可以实现以RAII手法管理堆区对象,但它设计的本意只是简单的利用C++对于栈区对象的自动析构管理堆区对象, 并不像shared_ptr那样包含引用计数,可以在每次拷贝的时候多出一个“分身”。这时候,拷贝的语义就成了很大的问题(按理说直接禁掉可能好好些), 于是就出 阅读全文
posted @ 2016-02-28 14:36 sfesly 阅读(1304) 评论(0) 推荐(0)
 
 

2016年2月25日

std::vector<bool>中的坑
摘要: http://www.cplusplus.com/reference/vector/vector/?kw=vector C++中,vector<bool>为了达到节省内存的目的,专门做了特化,大概方式就是用bit位来存储数组中的元素。代价就是,这个容器里面的内置类型乱掉了: member type 阅读全文
posted @ 2016-02-25 19:44 sfesly 阅读(3984) 评论(0) 推荐(0)
 
 

2016年1月23日

ubuntu 15.10 install nvidia driver
摘要: 先添加源sudo add-apt-repository ppa:graphics-drivers/ppa更新一下:sudo apt-get update(附原始链接:http://www.omgubuntu.co.uk/2015/08/ubuntu-nvidia-graphics-drivers-p... 阅读全文
posted @ 2016-01-23 20:58 sfesly 阅读(376) 评论(0) 推荐(0)
 
 

2016年1月6日

sync_with_stdio
摘要: /* The synchronization referred to is @e only that between the standard * C facilities (e.g., stdout) and the standard C++ objects (e.g., * cout).... 阅读全文
posted @ 2016-01-06 13:01 sfesly 阅读(310) 评论(0) 推荐(0)
 
What does it mean to “delegate to a sister class” via virtual inheritance?
摘要: Consider the following example:class Base {public: virtual void foo() = 0; virtual void bar() = 0;};class Der1 : public virtual Base {public: virtu... 阅读全文
posted @ 2016-01-06 09:46 sfesly 阅读(338) 评论(0) 推荐(0)
 
pimpl idiom vs. bridge design pattern
摘要: http://stackoverflow.com/questions/2346163/pimpl-idiom-vs-bridge-design-pattern 阅读全文
posted @ 2016-01-06 08:53 sfesly 阅读(191) 评论(0) 推荐(0)
 
 

2016年1月5日

c++ covariant return type
摘要: ... 阅读全文
posted @ 2016-01-05 15:55 sfesly 阅读(332) 评论(0) 推荐(0)
 
为什么需要虚析构函数?
摘要: When should my destructor be virtual?When someone will delete a derived-class object via a base-class pointer.In particular, here’s when you need to m... 阅读全文
posted @ 2016-01-05 14:16 sfesly 阅读(629) 评论(0) 推荐(0)
 
继承是为了被复用,而不是复用
摘要: 一般在一个框架库里面,我们继承一个库里已有的类,但是又不想把它周边的一套完全重整,所以希望我们定义的这个类能像类库里那个类一样到处能用,这时候只要我们保证把类库里原有的public接口全部完整实现(或者直接用基类的),就可以做到这一点。在有友元存在的情况下,记住友元也是类的一部分,要连带一起定义新的... 阅读全文
posted @ 2016-01-05 11:22 sfesly 阅读(332) 评论(0) 推荐(1)
 
How can I protect derived classes from breaking when I change the internal parts of the base class?
摘要: How can I protect derived classes from breaking when I change the internal parts of the base class?A class has two distinct interfaces for two distinc... 阅读全文
posted @ 2016-01-05 11:14 sfesly 阅读(178) 评论(0) 推荐(0)
 
 
下一页

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3