vendredi 1 février 2019

My integer insertion program in a chaining transforms integers from 16: (2,4,6,8,10,12,14,875311656,942421548,741355820)

Here is my insert method of a chaining class that I implement, the data type is integer (typedef int TELEM).By displaying the numbers stored, from 16 shows me other values too big

class list


private : 
     TELEM m_nb;
     TELEM *m_numbers;
public :
     ...//construc,destruct,methods

void list::insert(const TELEM& e, int i)
{  
  assert((i>=1) && (i<=m_nb+1));

  for (int k = m_nb ; k >= i ; --k)
    m_numbers[k+1] = m_numbers[k];      
  m_numbers[i] = e;
  std::cout << e <<std::endl;
  std::cout << m_numbers[i] <<std::endl;

  m_nb++;

}

for (int i=1; i<=10; ++i)
   myliste.insert(2*i,i);

from 16 ca gives me this (2,4,6,8,10,12,14,875311656,942421548,741355820) instead (2,4,6,8,10,12,14,16,18,20)

Aucun commentaire:

Enregistrer un commentaire