0

I am trying to understand deep and shallow copy concept and then to apply it. My class is composed of :int* num, bool signe and int pos. The copy is not working well, does anyone know why?

     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;
}
bandera
  • 49
  • 9
  • 2
    Do you also have a copy constructor, per the [Rule of Three](http://stackoverflow.com/questions/4172722)? Have you considered using `std::vector` to handle all the tedious pointer-juggling for you? – Mike Seymour Apr 06 '14 at 11:41
  • What do you mean by 'not working well'? Provide more details about the issue/error that you are facing. – rockoder Apr 06 '14 at 12:31
  • You are right, my constructor was not good. – bandera Apr 06 '14 at 14:05

0 Answers0