Changes

Jump to navigation Jump to search
Line 35: Line 35:  
==Constructors and Destructors==
 
==Constructors and Destructors==
 
A constructor is a class method that is automatically called when an instance of the class is instantiated.  The purpose of the constructor is to set up the new instance.  A destructor is a method that is called when an instance of the class is destroyed.  The purpose of the destructor is to clean up just prior to the instance being deleted.  Typically this includes freeing memory pointed to by instance data.  Some programming languages support special constructors called "copy constructors" which are called when an instance is created as a copy of another instance.
 
A constructor is a class method that is automatically called when an instance of the class is instantiated.  The purpose of the constructor is to set up the new instance.  A destructor is a method that is called when an instance of the class is destroyed.  The purpose of the destructor is to clean up just prior to the instance being deleted.  Typically this includes freeing memory pointed to by instance data.  Some programming languages support special constructors called "copy constructors" which are called when an instance is created as a copy of another instance.
 +
 +
The creation of an object instance is referred to as <i>constructing</i> or <i>instantiating</i> the instance.  Destroying the object is called <i>destructing</i>, <i>destroying</i>, or <i>freeing</i> the instance.
    
== Example (Java)==
 
== Example (Java)==
SkipCaptcha
292

edits

Navigation menu