mardi 5 janvier 2016

how to verify changes on objects after memory allocation

I have this code

classX* arrayX=new classEx[3];

// ..some code.. maybe the temp object was updated

//now need to check if at least one element was inserted into arrayEx

if (arrayX!=NULL){
  std::cout<<"The object is not empty, proceed";
  //some code
}
else{
  std::cout<<"Not even one element was inserted.Insert at least one new object";
}

My doubt is, Is that if (arrayX!=NULL) routine good to check for insertions?Please not suggest stl implementation(like vector). it must be that way

Aucun commentaire:

Enregistrer un commentaire