Thursday, June 17, 2010

Constructor

The constructor should have code only for initializing
the data members either with arguments or with some default values.

C# example
public Employee(string strName, int iAge)
{
 m_strName = strName;
 m_iAge = iAge;
}

Note: Use factory pattern for sophisticated construction of objects.

Rule: Have only initialization code in the constructor.

No comments: