17.10.1 Constructor initializers

原创 2006年05月21日 02:50:00
All instance constructors (except those for class object) implicitly include
an invocation of another instance
constructor immediately before the constructor-body. The constructor to
implicitly invoke is determined by the
constructor-initializer:
? An instance constructor initializer of the form base(argument-listopt)
causes an instance constructor from
the direct base class to be invoked. That constructor is selected using
argument-list and the overload
resolution rules of §14.4.2. The set of candidate instance constructors
consists of all accessible instance
constructors declared in the direct base class, or the default constructor (
§17.10.4), if no instance constructors
are declared in the direct base class. If this set is empty, or if a single
best instance constructor cannot be
identified, a compile-time error occurs.
? An instance constructor initializer of the form this(argument-listopt)
causes an instance constructor from
the class itself to be invoked. The constructor is selected using
argument-list and the overload resolution rules
of §14.4.2. The set of candidate instance constructors consists of all
accessible instance constructors declared
in the class itself. If that set is empty, or if a single best instance
constructor cannot be identified, a compiletime
error occurs. If an instance constructor declaration includes a constructor
initializer that invokes the
constructor itself, a compile-time error occurs.
If an instance constructor has no constructor initializer, a constructor
initializer of the form base() is implicitly
provided. [Note: Thus, an instance constructor declaration of the form
C(?) {?}
is exactly equivalent to
C(?): base() {?}
end note]
The scope of the parameters given by the formal-parameter-list of an
instance constructor declaration includes
the constructor initializer of that declaration. Thus, a constructor
initializer is permitted to access the parameters
of the constructor. [Example: For example:
class A
{
public A(int x, int y) {}
}
class B: A
{
public B(int x, int y): base(x + y, x - y) {}
}
end example]
An instance constructor initializer cannot access the instance being
created. Therefore it is a compile-time error to
reference this in an argument expression of the constructor initializer, as
it is a compile-time error for an
argument expression to reference any instance member through a simple-name.

Unity 3D 学习笔记

编辑器: Hierarchy窗口中是场景中的Game Object列表Project窗口中是磁盘上Assets文件夹中的内容,可用来创建Game Object 调试: 调试用Debug....
  • xuxiao537
  • xuxiao537
  • 2014年04月08日 21:03
  • 772

在写Mybatis时遇到的问题:No constructor found in 包名+类名

刚学习mybatis知识,就遇到很多小问题。当然是特别小,但是足够让我花费很多时间 我在mysql中创建了users表,是人的,有id, name,age;然后运用mybatis知识在eclipse...
  • xiaogaxuanyao
  • xiaogaxuanyao
  • 2016年06月29日 11:27
  • 3665

揭开js之constructor属性的神秘面纱

揭开 constructor 在 Javascript 语言中,constructor 属性是专门为 function 而设计的,它存在于每一个 function 的prototype 属性中。...
  • zengyonglan
  • zengyonglan
  • 2016年12月05日 15:06
  • 7141

js实例化以及constructor探究

js实例化以及constructor探究 先来一个构造函数: function Person(name){     this.name=name; } 对其添加原型链: Person.pr...
  • u012545279
  • u012545279
  • 2014年03月14日 16:16
  • 944

反射(构造方法Constructor的反射)

---------------------- ASP.Net+Android+IO开发S、.Net培训、期待与您交流! ----------------------   Java基础总结之反射(构造...
  • liukunaitasa
  • liukunaitasa
  • 2013年08月05日 16:53
  • 881

c++:构造函数(constructor)和析构函数(destructor)中编译器的隐式行为(implicit behavior)

【注:心急的可以通过目录直接看每段的结论;更心急的可以直接跳到最后看总结。但是这样的看法估计和教材里学到的差不多】 上篇文章提到,c++为了保证向前的兼容性和新加入的各种花哨功能,引入了很多隐式行为...
  • madongchunqiu
  • madongchunqiu
  • 2014年03月28日 22:37
  • 4710

c++: 构造函数(constructor)与各种眼花缭乱的初始化(initialization)

本文是作为下一篇文章的前置。首发地址:http://blog.csdn.net/madongchunqiu/article/details/22325357 【注:灰色文字,不耐可略过。】 话说我...
  • madongchunqiu
  • madongchunqiu
  • 2014年03月28日 01:05
  • 11440

JS constructor探讨(一):为什么要设置prototype.constructor?

每次实现JS的继承时,代码里必有如下两句:// 用于设置原型 Employee.prototype = new Person() // 设置原型的构造器 Employee.prototype.co...
  • yiifaa
  • yiifaa
  • 2017年05月30日 13:52
  • 264

JavaScript中对象的 constructor 属性的介绍

作者:傅智威 链接:https://www.zhihu.com/question/19951896/answer/102946428 来源:知乎 著作权归作者所有。商业转载请联系作者获得授权,非...
  • u013147600
  • u013147600
  • 2016年06月02日 16:03
  • 701

彻底深刻理解js原型链之prototype,__proto__以及constructor(一)

原文地址:http://www.0313.name/2017/01/13/prototype-proto-constructor.html前言 以下概念请花费一定的时间彻底理解,才能进行下一步,思...
  • zhangliuxiaomin
  • zhangliuxiaomin
  • 2017年01月19日 18:14
  • 751
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:17.10.1 Constructor initializers
举报原因:
原因补充:

(最多只允许输入30个字)