在编程语言构造 [英] Constructors in Programming languages
问题描述
为什么构造
不被视为成员
一类的?
有没有什么具体的原因是什么?
Why constructor
is not considered as member
of a class ?
Is there any specific reason ?
感谢和问候。
推荐答案
我拒绝了问题的premise。构造函数的是的在C#类或结构的成员。
I reject the premise of the question. A constructor is a member of a class or struct in C#.
我是指你第3.4.4 C#的规范,它列举了类的成员(类成员):
I refer you to section 3.4.4 ("Class members") of the C# specification, which enumerates the members of a class:
一个类声明可能包含 常量,字段的声明, 方法,属性,事件,索引器, 运算符,实例构造函数, 析构函数,静态构造函数和 类型。
A class declaration may contain declarations of constants, fields, methods, properties, events, indexers, operators, instance constructors, destructors, static constructors and types.
显然,构造函数是一个类的成员。为什么你认为一个构造函数是不是会员?谁告诉你的谎言吗?
Clearly constructors are members of a class. Why do you believe that a constructor is not a member? Who told you that lie?
这篇关于在编程语言构造的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!