c++protected是什么意思

如题所述

  C++:protected访问说明符 。一个类自身的对象是可以访问protected的成员的 ,protected类型的成员在一个类中与pravite类型的成员性质亦一样的,只是在派生继承时性质不同,pravite不能被派生出来的类(也就是子类)调用(访问),而protected是可以被派生出来的类调用的。
  protected专门就是为继承(子类)设计的 用public继承 那么基类所有的访问标识在子类不变 protected还是protected protected只有类本身 和类的子类可以访问,对象是无法访问的。
  有这么一条原则:在继承的时候,无论用什么方式(public.protected.private),子类随时都可以访问父类的非private变量或函数。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-12-15
c++protected
C + +保护

protected
[英][prə'tektɪd][美][prə'tektɪd]
v.防护; 保护( protect的过去式和过去分词 ); 投保; 关税保护;

例句
1 In the past, the region had been protected by its forbidding geography and the extremities of its climate.
过去,这个地区令人生畏的地理条件和极端的天气状况使它受到保护。
2 This cache is protected but not encrypted, and is backed up in iTunes whenever you back up your iPhone.
这块缓存是受保护的,但没有被加密,当你用iTunes备份iPhone时,缓存也会备份。
3 No less than 35 per cent of the country is protected in the form of parks and nature sanctuaries.
该国多达35%的地区以公园和自然保护区的形式受到保护。
第2个回答  2015-03-15
奇怪不让发代码
protected是访问控制,对外不允许访问类似private,对于子类允许访问,类似public.

public protected private

public继承 public protected 不可用

protected继承 protected protected 不可用

private继承 private private 不可用本回答被网友采纳
相似回答