我可以说构造函数是方法吗? [英] Can I say a Constructor is a Method?

查看:116
本文介绍了我可以说构造函数是方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我是否可以说构造函数方法的特例?

I wonder if can I say that a constructor is a special case of a method?

推荐答案

您可以说任何话.是否有人会不同意您取决于上下文.一些语言社区和标准以这种方式定义事物.

You can say anything. Whether anyone will disagree with you depends on the context. Some language communities and standards define things that way.

更详细地说,这取决于您所指的方法".例如,在C ++中,分析创建过程的一种方法是说它包括对操作符new的调用(也许只是放置),然后对构造函数 method 的调用.从实现的角度来看,构造函数看起来,走动和发出嘎嘎声都像一种方法.在某些编译器中,您甚至可以显式调用一个编译器.

More elaborately, it depends on what you mean by a 'method.' In C++, for example, one way to analyze the creation process is to say that it consists of a call to an operator new (perhaps just placement) followed by a call to a constructor method. From an implementation standpoint, a constructor looks, walks, and quacks like a method. In some compilers, you can even invoke one explicitly.

从理论上讲,有人可能会说构造函数是一些独特的物种.但是,没有方法,构造函数或紫色独角兽的单一,真实,特权概念模型.

From a more theoretical viewpoint, someone might claim that constructors are some distinctive species. However, there is no single, true, privileged conceptual model of methods, constructors, or purple unicorns.

天哪,这都是主观的.

这篇关于我可以说构造函数是方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆