Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C++ Builder > Подскажите в чем отличие


Автор: Teran 19.7.2006, 16:20
Подскажите в чем отличие и как правильно уничтожать форму?: 
Код

..........
Application->CreateForm(__classid(TForm1), &Form1);
.....
Form1->Free();
.......

и
Код

..........
Application->CreateForm(__classid(TForm1), &Form1);
.....
delete Form1;
.....

 smile  smile  smile  

Автор: dumb 19.7.2006, 16:28
Цитата

Do not call the Free method of an object. Instead, use the delete keyword, which invokes Free to destroy an object. Free automatically calls the destructor if the object reference is not NULL.
 

Автор: Teran 19.7.2006, 16:34
Спасибо!
Буду испоьзовать Delete 

Автор: Romikgy 19.7.2006, 16:45
А по моему лучше фри 

Автор: Teran 19.7.2006, 17:02
Так на чемже можно остановиться всетаки?  smile  

Автор: DemoCode 19.7.2006, 17:03
А разве есть разница? 

Автор: dumb 19.7.2006, 18:18
Better Programming Practices in C++Builder:
Цитата

WARNING

Never call a VCL object's Free() method to destroy a VCL object. Always use delete. This ensures that the object's destructor is called and that the memory allocated previously with new is freed. Free() does not guarantee this, and it is bad practice to use it.


тонкий намек на то, что Free() могут и перекрыть. 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)