Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Usage of "new" and "delete" in U++
Usage of "new" and "delete" in U++ [message #27135] Sun, 27 June 2010 15:41 Go to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
From the “manual” in the web one can see that new and delete are not present in U++. Does this mean that ALL the widgets are created statically and therefore they are created at compilation time?

If the answer is yes, the implication is that when the application terminates ALL the objects (widgets, classes, etc..) are deleted automatically (with the exception of the objects created with new)

What do you think?

Thank you,

Javier
Re: Usage of "new" and "delete" in U++ [message #27137 is a reply to message #27135] Sun, 27 June 2010 15:54 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Read it:
http://www.ultimatepp.org/www$uppweb$overview$en-us.html

All screen object are stack object.

And this very usual!

All screen object - the object stack.

And it is very convenient!
When we leave the area of life the object - it is removed.

There is no need garbage collectors.

For complex structures use the containers.

Description of the containers are here:
http://www.ultimatepp.org/srcdoc$Core$Tutorial$en-us.html


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Usage of "new" and "delete" in U++ [message #27141 is a reply to message #27135] Sun, 27 June 2010 22:56 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
It is possible to create widgets on stack or on heap, but U++ developers encourage to use stack because C++ take care of allocated memory, so you won't have to think about allocations/deallocation problems. There are only few times when you need to allocate on heap, you may had encounter that in U++ GUI Tutorial, point 6 - "Multiple main windows". I think it's better to use every feature from the language (let compiler take care of your memory) and don't complicate you're self with new/delete. Use pointers only to point to things.

Andrei
Re: Usage of "new" and "delete" in U++ [message #27150 is a reply to message #27135] Mon, 28 June 2010 17:20 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
new and delete of course are present. Smile
But usually you don't need them, when you work in U++ way of doing things.
Re: Usage of "new" and "delete" in U++ [message #27151 is a reply to message #27135] Mon, 28 June 2010 20:02 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
281264 wrote on Sun, 27 June 2010 09:41

From the “manual” in the web one can see that new and delete are not present in U++. Does this mean that ALL the widgets are created statically and therefore they are created at compilation time?



No.

What is going on is that heap is considered an implementation detail that should not be exposed in any interfaces.

Thus all U++ interfaces are designed to work without heap objects and that is why you do not see many new/deletes in the normal high-level code.

Also, for program logic, most cases where heap/new/delete was/is required in normal C/C++ programming are solved by using U++ containers.
Previous Topic: U++ vs Qt
Next Topic: Message from the system.
Goto Forum:
  


Current Time: Thu Mar 28 11:04:21 CET 2024

Total time taken to generate the page: 0.01404 seconds