3 ms·
> Saying "using RAII for memory management" is insufficient - with just RAII, you cannot even assign a class into a passed-in variable. What exactly do you mea
by zabzonk 4mo ago
> Saying "using RAII for memory management" is insufficient - with just RAII, you cannot even assign a class into a passed-in variable.
What exactly do you mean by " assign a class into a passed-in variable"? Please post some code illustrating what you are talking about.
- theamk 4mo agofunction make_widget(parent& x): w = new Widget() x.children.add(w) RAII is not going to help you here, you need something else (move semantics or refcount-based GC are most common, but other choices exist too). If this one is too easy, make function return "w" as well, or make it add a widget to two different lists
- zabzonk 4mo agoWell, if this is supposed to be something like C++, and if "new" is dynamically allocating memory, then simply don't do that - this kind of thing has been solved years ago.
- deleted 4mo ago[deleted]