B****S 发帖数: 597 | 1 A derived object may access the protected members of its base class only
through a derived object. The derived class has no special access to the
protected members of base type objects.
真是你妹啊。 |
t*****n 发帖数: 4908 | 2 技术牛人写书就是这风格。所以教书匠不一定是牛人,牛人不一定适合教书。
【在 B****S 的大作中提到】![](/moin_static193/solenoid/img/up.png) : A derived object may access the protected members of its base class only : through a derived object. The derived class has no special access to the : protected members of base type objects. : 真是你妹啊。
|
B****S 发帖数: 597 | 3 C++出来的还是太早了,设计上面太多的否定之否定,什么情况都想cover。搞得细节太多。
技术牛人就是这种风格,以为其他人都和他一样牛。
别人还要干别的事情,又不是和他一样把所有时间都花在那个上面了。能帮助别人省时
间的才是牛人。
【在 t*****n 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 技术牛人写书就是这风格。所以教书匠不一定是牛人,牛人不一定适合教书。
|
t*****n 发帖数: 4908 | 4 这也不是缺点。每种语言都有垃圾冗余的地方。只看细节,没啥意思。语言就是来干活
的。
多。
【在 B****S 的大作中提到】![](/moin_static193/solenoid/img/up.png) : C++出来的还是太早了,设计上面太多的否定之否定,什么情况都想cover。搞得细节太多。 : 技术牛人就是这种风格,以为其他人都和他一样牛。 : 别人还要干别的事情,又不是和他一样把所有时间都花在那个上面了。能帮助别人省时 : 间的才是牛人。
|
c*****n 发帖数: 75 | 5 〉〉“真是你妹啊”
这段话有什么问题吗?首先,你漏掉了这段话前的 "In Addition, protected has
another important property: A derived object...."
在结合书中这段话后面的的例子, 这段话的意思非常清楚了。并无冗余。
以下是摘要全段:
In addition, protected has another important property:
· A derived object may access the protected members of its base class only
through a derived object. The derived class has no special access to the
protected members of base type objects.
As an example, let's assume that Bulk_item defines a member function that
takes a reference to a Bulk_item object and a reference to an Item_base
object. This function may access the protected members of its own object
as well as those of its Bulk_item parameter. However, it has no special
access to the protected members in its Item_base parameter:
void Bulk_item::memfcn(const Bulk_item &d, const Item_base &b)
{
// attempt to use protected member
double ret = price; // ok: uses this->price
ret = d.price; // ok: uses price from a Bulk_item object
ret = b.price; // error: no access to price from an Item_base
}
The use of d.price is okay, because the reference to price is through an
object of type Bulk_item. The use of b.price is illegal because Bulk_item
has no special access to objects of type Item_base. |
B****S 发帖数: 597 | 6 难道我的英语不过关?
only
【在 c*****n 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 〉〉“真是你妹啊” : 这段话有什么问题吗?首先,你漏掉了这段话前的 "In Addition, protected has : another important property: A derived object...." : 在结合书中这段话后面的的例子, 这段话的意思非常清楚了。并无冗余。 : 以下是摘要全段: : In addition, protected has another important property: : · A derived object may access the protected members of its base class only : through a derived object. The derived class has no special access to the : protected members of base type objects. : As an example, let's assume that Bulk_item defines a member function that
|
m*******l 发帖数: 12782 | 7 clas != object
【在 B****S 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 难道我的英语不过关? : : only
|
l*********s 发帖数: 5409 | |
B****S 发帖数: 597 | 9 理论上,c++ primer应该包括所有东西了,虽然细节未必面面俱到。
【在 l*********s 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 还以为这本是给初学者用的,看来还是有点花头的。
|
B****S 发帖数: 597 | 10 class里面函数还调用class本身的object,这种做法应该不值得推广把。很容易死循环
阿。
【在 m*******l 的大作中提到】![](/moin_static193/solenoid/img/up.png) : clas != object
|