Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I say a Constructor is a Method? [closed]

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

like image 683
The Student Avatar asked Sep 05 '10 14:09

The Student


1 Answers

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

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.

Gosh this is all subjective.

like image 60
bmargulies Avatar answered Oct 15 '22 16:10

bmargulies