Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
C++ section: Clarified part about copy ctors.
Changing "ColdFusion" to "CFML": CFML is the language; ColdFusion is a vendor implementation. Adding code example for initmethod
Line 365:
</source>
 
=== ColdFusionCFML ===
 
[[ColdFusionCFML]] uses a method named '<code>init</code>' as a constructor method.
 
'''Cheese.cfc'''
<source lang="javascript">
component displayname="Cheese" {
// properties
property name="cheeseName";
Line 386:
<source lang="javascript">
myCheese = new Cheese( 'Cheddar' );
</source>
 
Since ColdFusion 10<ref>[https://wikidocs.adobe.com/wiki/display/coldfusionen/cfcomponent CFComponent]</ref>, CFML has also supported specifying the name of the constructor method:
 
<source lang="javascript">
component initmethod="Cheese" {
// properties
property name="cheeseName";
 
// constructor
function Cheese Cheese( required string cheeseName ) {
variables.cheeseName = arguments.cheeseName;
return this;
}
}
</source>