Constructors in Nonvisual Parts

Nonvisual parts should have a default constructor. An example of the IAddress class default constructor follows:

IAddress();

The implementation of the standard constructor for the IAddress class follows:

  IAddress::IAddress() : IStandardNotifier(),
    iStreet("101 Main Street"),
    iCity("Hometown"),
    iState("NC"),
    iZip("27511")
  {
  }

For most nonvisual parts, supply a copy constructor. An example follows:

IAddress (const IAddress& partCopy);

The implementation of the copy constructor for IAddress follows:

  IAddress::IAddress (const IAddress& partCopy)    : IStandardNotifier (partCopy),
    iStreet(partCopy.street()),
    iCity(partCopy.city()),
    iState(partCopy.state()),
    iZip(partCopy.zip())
  {
  }


Related concepts
Destructors in Nonvisual Parts
Assignment Operators in Nonvisual Parts