由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 请问C++小白问题
相关主题
相关话题的讨论汇总
话题: class话题: access话题: member话题: base话题: derived
进入Programming版参与讨论
1 (共1页)
x******a
发帖数: 6336
1
derived class inherits every member of the base class but derived classs can
not access to the private member of the base class?
here what is the difference between "inherits" and "access"?
a****l
发帖数: 8211
2
打个比方说,一个富商包养了一个二奶,把自己的一套房子给二奶住.二奶住在富商的房
子里就和住在自己的家里一样方便,但是二奶没办法把这套房子卖了赚钱.这种情况下就
可以说"二奶"这个object是"inherit"了"富商"object的这个"房子"member,但是没有这
个房子的"access".

can

【在 x******a 的大作中提到】
: derived class inherits every member of the base class but derived classs can
: not access to the private member of the base class?
: here what is the difference between "inherits" and "access"?

x******a
发帖数: 6336
3
"access“是访问还是修改?
S**I
发帖数: 15689
4
both

【在 x******a 的大作中提到】
: "access“是访问还是修改?
r*******y
发帖数: 1081
5
you can inherit any class, but can you expect to access the base class'
private
member ?

can

【在 x******a 的大作中提到】
: derived class inherits every member of the base class but derived classs can
: not access to the private member of the base class?
: here what is the difference between "inherits" and "access"?

f*****e
发帖数: 2992
6
如果想访问还是有办法滴。

can

【在 x******a 的大作中提到】
: derived class inherits every member of the base class but derived classs can
: not access to the private member of the base class?
: here what is the difference between "inherits" and "access"?

r*******y
发帖数: 1081
7
for example?

【在 f*****e 的大作中提到】
: 如果想访问还是有办法滴。
:
: can

c**********e
发帖数: 2007
8
这个比方好像打反了。二奶住在房子里,所以有access,但是没有inherit这个房子,
也就是没有所有权。
子类刚好相反,它继承了所以有基类的成员,但是接触不了这些成员。比方说,你有某
房的产权(房产证),但是钥匙在租户或你委托的管理公司手里,所以你进不了房子。

【在 a****l 的大作中提到】
: 打个比方说,一个富商包养了一个二奶,把自己的一套房子给二奶住.二奶住在富商的房
: 子里就和住在自己的家里一样方便,但是二奶没办法把这套房子卖了赚钱.这种情况下就
: 可以说"二奶"这个object是"inherit"了"富商"object的这个"房子"member,但是没有这
: 个房子的"access".
:
: can

a***y
发帖数: 2803
9
初级问题.为了privacy. inherit的是base class,但是可以用的只是某些public和
protected函数.

can

【在 x******a 的大作中提到】
: derived class inherits every member of the base class but derived classs can
: not access to the private member of the base class?
: here what is the difference between "inherits" and "access"?

f*z
发帖数: 421
10
富/官二代(derived class)可以继承父亲(base class)的一切, 但是父亲的二奶(
private member)无法直接玩弄 (access).可以通过public member function,比如get,
set之类的间接访问。

can

【在 x******a 的大作中提到】
: derived class inherits every member of the base class but derived classs can
: not access to the private member of the base class?
: here what is the difference between "inherits" and "access"?

v*****r
发帖数: 2325
11
zan this analogy, 真有想象力

get,

【在 f*z 的大作中提到】
: 富/官二代(derived class)可以继承父亲(base class)的一切, 但是父亲的二奶(
: private member)无法直接玩弄 (access).可以通过public member function,比如get,
: set之类的间接访问。
:
: can

s***n
发帖数: 459
12
derived class 和 base class 并不是你和你爸的关系,而是人和哺乳动物的关系。
a***y
发帖数: 2803
13
对.

【在 s***n 的大作中提到】
: derived class 和 base class 并不是你和你爸的关系,而是人和哺乳动物的关系。
1 (共1页)
进入Programming版参与讨论
相关主题
相关话题的讨论汇总
话题: class话题: access话题: member话题: base话题: derived