I'm writing a class that contains a array allocated dynamic of floats. I need to implement an assignment operator that is overloaded to assign the contents of one array to another.
Here's what I have so far (the class is called ArrayB):
ArrayB & operator= (const ArrayB & other)
{
if (this != &other)
{
//Logic goes here to assign arrays
}
return *this;
}
}
I'm having problems trying to figure out the logic and code to assign arrays to one another with dynamic allocation. Can someone help me out?
No, I haven't. I thought that I needed to write the assignment operator first so that I could use it in the copy constructor. Is that not correct? Is it the opposite way around, I have to do the constructor first so I can use it in the assignment operator?