View Single Post
  #5 (permalink)  
Old April 30th, 2004, 02:51 AM
gbilios gbilios is offline
Authorized User
 
Join Date: Mar 2004
Posts: 33
Thanks: 0
Thanked 1 Time in 1 Post
Default

This modified the copy constructor as follows

//COPY CONSTRUCTOR
   BookItem::BookItem(const BookItem& bkObject)
    :StockItem(bkObject), Authors(bkObject.GetAuthors()),Title(bkObject.GetT itle()),
        pub(new Publisher(bkObject.pub->GetName())), Year(bkObject.GetYear())
   {

   }

I changed the following for the assignment operator overloading
BookItem BookItem::operator=(const BookItem& temp)
   {

  if (this == &temp)
  {
  // IF THE RIGHT SIDE IS THE SAME AS THE LEFT SIDE
    return *this;
  }
    else
    {
    delete pub;
    Authors = temp.Authors;
    Title = temp.Title;
    pub = new Publisher(temp.pub->GetName());
    Year = temp.Year;

   return *this;
   } // end if

   }
Thanks for your help
Reply With Quote