salam 3alekom
i really need help with this, anyone please ASAP. i am waiting. thanks so much,,,,by the way this is my firtst time here.
The SetBase member function of the Array class defined in Program simply changes the value of the base member variable. As a result, after the base is changed, all the array elements appear to have moved. How might the routine be modified so that the elements of the array don't change their apparent locations when the base is changed?
//
// This file contains the C++ code from Program 4.8 of
// "Data Structures and Algorithms
// with Object-Oriented Design Patterns in C++"
// by Bruno R. Preiss.
//
//
template
void Array::SetBase (unsigned int newBase)
{ base = newBase; }
template
void Array::SetLength (unsigned int newLength)
{
T* const newData = new T [newLength];
unsigned int const min =
length < newLength ? length : newLength;
for (unsigned int i = 0; i < min; ++i)
newData = data ;
delete [] data;
data = newData;
length = newLength;
}