14.1 In terms of inheritance, what is the effect of keeping a constructor private?

这道题问我们用继承特性时,如果建立一个私有的构建函数会怎样。

只有能访问该函数的私有变量或函数的东西才能访问私有构建函数,比如内部类就可以访问,比如类A是类Q的一个内部类,那么Q的其他内部类可以访问类A的私有构建函数。

由于一个子类可以调用父类的构建函数,类A可以被继承,所以只有类A的子类或者是类Q的其他子类可以访问类A的私有构建函数。

[CareerCup] 14.1 Private Constructor 私有构建函数的更多相关文章

  1. [CareerCup] 14.5 Object Reflection 对象反射

    14.5 Explain what object reflection is in Java and why it is useful. Java中的对象反射机制可以获得Java类和对象的反射信息,并 ...

  2. 私有虚函数的特点(C++和Java的机制还有所不同)

    多态性与将实现多态的函数的访问限定符没有任何关系,private 函数仍然可以实现多态,它的指针仍然位于vtbl中,只不过该函数的多态一般只能在基类的内部由其他非虚函数调用该函数的时候反映出来,访问限 ...

  3. TWinControl与TControl的覆盖函数(TWinControl对TControl的10个消息覆盖函数,17个覆盖函数,私有虚函数仍可多态)

    手工找出来,对比一下,有助于VCL框架的理解.----------------------------------------------------------------------------- ...

  4. C# empty private constructor

    A private constructor is a special instance constructor. It is generally used in classes that contai ...

  5. Effective Java 03 Enforce the singleton property with a private constructor or an enum type

    Principle When implement the singleton pattern please decorate the INSTANCE field with "static ...

  6. Effective Java 04 Enforce noninstantiability with a private constructor

    A class can be made noninstantiable by including a private constructor. // Noninstantiable utility c ...

  7. Effective Java Item4:Enforce noninstantiability with a private constructor

    Item4:Enforce noninstantiability with a private constructor 通过构造私有化,禁止对象被实例化. public class UtilClass ...

  8. Effective Java Item3:Enforce the singleton property with a private constructor or an enum type

    Item3:Enforce the singleton property with a private constructor or an enum type 采用枚举类型(ENUM)实现单例模式. ...

  9. js构建函数优秀案例

    这几个效果函数是看到别人写的,挺好的,复制下来学习备用! 函数封装: //var _hmt = _hmt || [];(function() {var hm = document.createElem ...

随机推荐

  1. eclipse执行单元测试报CreateProcess error=87的解决方法

    原因是classpath的路径过长导致,在网上看了很多文章,发现解决方法有2种: 1.更改项目路径 或者 maven本地库的路径,减少classpath的深度. 2.由于这是eclipse自身的bug ...

  2. Android Studio 有用的插件

    从Eclipse切换到Android Studio 有一段时间了,发现as同,github,已经很多插件的集合有强大的合成效应. 安装插件请参考:http://blog.csdn.net/hyr839 ...

  3. JavaScript Patterns 3.3 Patterns for Enforcing new

    When your constructor has something like  this.member and you invoke the constructor without  new,  ...

  4. java打字游戏

    小记:老早之前写的程序,今天发现之前在 csdn上写的东西的图片不显示了,搞得人好郁闷,所以把之前零星的几篇文章搬个家 游戏运行截图: 字母实体类 package com.git.game; impo ...

  5. jQuery最佳实践(不断更新中...)

    1. 处理cdn失效 <script type="text/javascript" src="http://xxx.com/jquery.min.js " ...

  6. 一次由于字符集问题引发的MySQL主从同步不一致问题追查

    近期业务准备上线一个新功能,灌入数据之后突然发现主从同步停止,报错如下: Error 'Duplicate entry '66310984-2014-04-18 00:00:00--122815.sh ...

  7. Windows环境下JDK安装与环境变量配置详细的图文教程

    原文作者:souvc博文出处:http://www.cnblogs.com/liuhongfeng/p/4177568.html 本节内容:JDK安装与环境变量配置 以下是详细步骤 一.准备工具: 1 ...

  8. Linux shell misc

    sometimes you will write shell in windows platform, be careful for this, adjust the notepad plus plu ...

  9. Sql Practice 2

    之前写了一个SP用来向dimention table插入0 -1 dummy row的值,但今天在process adventureworksdw2008示例 数据库的时候报错,查看了一下,是因为自己 ...

  10. NOIP2007 T2纪念品分组 解题报告-S.B.S.

    #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #inclu ...