当前位置:首页 > 文献资料 > 正文

protected和private区别

二者的区别主要在权限问题上,protected 是受保护的,只有当前类的成员与继承该类的类才能访问;private是完全私有的,有当前类中的成员能访问到。

protected和private区别

1、protected

adj. 受保护的。动词protect的过去式和过去分词形式。

句子示例:

It's against the law to kill protected animal.

屠杀被保护动物是违法的。

As the protected infant industries grow, their costs sometimes fail to decline.

当受保护的新兴工业增长时,有时成本无法降低。

2、private

adj. 私人的;个人的;私下的;私有的;缄默的;为一部份人的;内心的;与工作无关的。

n. 士兵;列兵。

句子示例:

She is a very retiring and private person.

她是个非常孤独缄默的人。

We each have our private views about it.

我们每个人对这件事都有自己的看法。