Assignment Operator 2
- First attempt: same as copy constructor
IntArray& IntArray::operator =(const IntArray& b)
{
size_ = b.size_;
data_ = new int [size_];
// check for failed allocation
for (size_t i = 0; i < size_; ++i)
data_[i] = b.data_[i];
return *this;
}
Problem: What happens to memory already allocated to a ?