我正在尝试理解深度和浅层复制概念,然后应用它。 我的类由:int * num,bool signe和int pos组成。 副本效果不好,有谁知道为什么?
CBigInt & operator= (const CBigInt & other)
{
if (this != &other)
{
int * new_array = new int[30000000];
std::copy(other.num, other.num+ other.pos+ other.signe, new_array);
delete [] num;
num = new_array;
pos = other.pos;
signe=other.signe;
}
return *this;
}