TListBox * lbx2; //обьявил локально if (??????) { //если компонент такой сущесвует (lbx2) или если выделена память for (int j(0); j < lbx2 - > Items - > Count; j++) { tstn[j] - > Release(); Application - > ProcessMessages(); } lbx2 - > Clear(); } else { //либо создаем такой компонент lsbx = new TStringList(GridLayout2); lbx2 = new TListBox(GridLayout2); } 

That's what substitute where the question marks?

  • lbx2 != nullptr ? - user194374

2 answers 2

 TListBox * lbx2 = 0; //... if (lbx2 != 0) 
  • 2
    For pointers it is not recommended to use literal 0 . Modern C ++ recommends using nullptr . Or at least a NULL macro. - user194374
  • nullptr is already C ++ 0x, NULL - could redefine define. So no - you need to use 0 in the good old C ++ - Sublihim
  • @Sublihim when NULL someone overrides this already wrecking. You will not give up true / false only for the reason that someone can write #define true false . NULL , like nullptr easier to search in the text than the usual 0 . - αλεχολυτ
  • I am guided by stroustrup.com/bs_faq2.html#null why not trust? Responding to stackoverflow.com/questions/176989/… says quite to itself about it - Sublihim
  • 2
    Do not argue, hot Finnish guys! Write simple and simple - if(lbx2) ... - Harry
 TListBox * lbx2 = NULL; if (lbx2) { //если компонент такой сущесвует (lbx2)или если выделена память 
  • it is better to use 0 if it is C ++ - Sublihim
  • @Sublihim Not better. Perhaps the existence of platforms where the zero address is valid. - user194374