Your Ad Here

Wednesday, October 22, 2008

Constructors

The ENGLOBJ example shows two ways that member functions can be used to give values to the data items in an object. Sometimes, however, it’s convenient if an object can initialize itself when it’s first created, without the need to make a separate call to a member function. Automatic initialization is carried out using a special member function called a constructor. A constructor is a member function that is executed automatically whenever an object is created. (The term constructor is sometimes abbreviated constructor, especially in program listings.)

No comments: