Beispiel #1
0
 /////////////////////////////////////
 //
 //   C O P Y  -  C O N S T R U C T O R
 //
 /////////////////////////////////////
 // Pre-Condition: object of type ID passed as value parameter.
 // Post-Condition: return value is a value of class ID
 ID::ID( const ID& origID )
 {
   // pass original as a vlaue paraeter
   // initializes a new object from an existing object.
   // copies the values in the data members from the origID
   // uses new to allocate a new name_ char array pointer by origID
   name_ = new char[ 10 ];
   // char *tempPtr = origID->GetName();
   this->SetName( origID.GetName() );
   this->SetAge( origID.GetAge() );
 }
Beispiel #2
0
//copy constructor
ID::ID(const ID& rhs): name_(0), age_(0)
{
  SetName(rhs.GetName());
  SetAge(rhs.GetAge());
}