The members of a nested class have no special access to members of an enclosing class, nor to classes or functions that have granted friendship to an enclosing class; the usual access rules (clause 11) shall be obeyed. The members of an enclosing class have no special access to members of a nested class; the usual access rules (clause 11) shall be obeyed.
Example:
classE { int x; class B { }; classI {
B b; // error: E::B is private int y; void f(E* p, int i) {
p->x = i; // error: E::x is private
}
}; int g(I* p)
{ return p->y; // error: I::y is private
}
};
但是在 C++11 中,这段描述变更为:
$11.7/1 Nested classes [class.access.nest]
A nested class is a member and as such has the same access rights as any other member. The members of an enclosing class have no special access to members of a nested class; the usual access rules (Clause 11) shall be obeyed.
Example:
classE { int x; class B { }; classI {
B b; // OK: E::I can access E::B int y; void f(E* p, int i) {
p->x = i; // OK: E::I can access E::x
}
}; int g(I* p) { return p->y; // error: I::y is private
}
};
这个周末在家看吴军先生的《浪潮之巅》,爱不释手。作为一个曾经拜读过 Google 中国黑板报上“浪潮之巅”系列连载的读者,我本以为这会是本信息企业史,但阅读后发现新增的三分之一内容更精彩。我不曾想过一个技术人员的眼界会如此之广,能够从各个角度去观察和分析身处的这个行业、这个时代。我不否认对于书中的一些观点我并不完全赞同,但作者的眼界和思考能力着实让我佩服。
...if structure members are outside their valid interval, they will be normalized
(so that, for example, 40 October is changed into 9 November);...
这就意味着,对输入时间做严格的检查无法依赖于标准库中的 mktime() 函数,只能自己来进行。这应该也是 date 命令曾经改进过的地方。
$ date -d "2011-13-32" # date (coreutils) 5.2.1
Wed Feb 1 00:00:00 CST 2012
$ date -d "2011-13-32" # date (GNU coreutils) 8.5
date: invalid date `2011-13-32'
基于应用场景的数据特征,Facebook 抽象出了几个对存储系统的需求。由于描述起来有些复杂,例如 Efficient and low-latency strong consistency semantics within a data center,这些需求就不一一列举了。相比需求,更让人感兴趣的是它的那些“非需求”,总共有三条: