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
|