会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
sfesly
博客园
首页
新随笔
联系
订阅
管理
2015年12月21日
Why am I getting an error converting a Foo** → const Foo**?
摘要: Because converting Foo** → const Foo** would be invalid and dangerous.C++ allows the (safe) conversion Foo* → Foo const*, but gives an error if you tr...
阅读全文
posted @ 2015-12-21 17:20 sfesly
阅读(214)
评论(0)
推荐(0)
编辑
The constness of a method should makes sense from outside the object
摘要: C++的encapsulation机制使得我们可以使得一个类的逻辑接口和内部表示有很大的差异,比如下面这个矩形类:class Rectangle{public: int width() const {return x;} int height() const {return y;} ...
阅读全文
posted @ 2015-12-21 16:47 sfesly
阅读(183)
评论(0)
推荐(0)
编辑
Virtual Friend Function
摘要: 一般而言,友元作为一种紧耦合的设计,被视作类的一部分。一个经典的应用就是关于类的序列化和反序列化。class A{ friend ostream& operator<<(ostream& os, const A& a);private: int i;}ostream& operator<...
阅读全文
posted @ 2015-12-21 13:51 sfesly
阅读(229)
评论(0)
推荐(0)
编辑
公告