Home » Community » Coffee corner » Pointers or not?
Pointers or not? [message #58103] |
Tue, 15 February 2022 10:14 |
AtlantikBlu
Messages: 1 Registered: February 2022
|
Junior Member |
|
|
Sorry for my english language, I'm italian.
I'm new in U++, and read official tutorial I look that in examples are declared only object vars like:
TowWindow tw or
Button b
and not
TopWindow* tw or
Button* b
Why not use pointers?
In this manner, full the stack memory ???
Thanks
|
|
|
Re: Pointers or not? [message #58120 is a reply to message #58103] |
Sat, 19 February 2022 22:59 |
|
Klugier
Messages: 1075 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello,
The short answer is yes. We use stack memory instead of heap. One of the reason is better performance with stack rather than heap. Please noticed, that you could still use heap, but it is wast of time and needs extra caution. You need to remember to use free/delete. The general rule is do not use heap allocation for widgets.
More information you could find in following overview section. Also, please read the whole document very closely. There are several referrals to your question such as this.
Klugier
U++ - one framework to rule them all.
[Updated on: Sat, 19 February 2022 23:04] Report message to a moderator
|
|
|
Re: Pointers or not? [message #58129 is a reply to message #58120] |
Tue, 22 February 2022 10:33 |
zsolt
Messages: 693 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
These U++ classes internally allocate memory from heap, but you don't have to deal with it.
You can use them on stack or in containers.
We have projects with ten thousands of lines without any new operator. Life is much better without it. No more memory leaks, no pointers pointing to deleted objects.
|
|
|
Goto Forum:
Current Time: Thu Mar 28 19:56:34 CET 2024
Total time taken to generate the page: 0.01488 seconds
|