Home » U++ Library support » LineEdit, EditFields, DocEdit » operator<<= in tree control reference example
operator<<= in tree control reference example [message #30497] |
Wed, 05 January 2011 10:55 |
gprentice
Messages: 260 Registered: November 2005 Location: New Zealand
|
Experienced Member |
|
|
In the tree control reference example there is this code
void LoadTree(int parent, const String& path, Progress& pi)
{
pi.SetText(DeFormat(path));
for(FindFile ff(AppendFileName(path, "*.*")); ff; ff.Next()) {
if(pi.StepCanceled())
return;
String n = ff.GetName();
if(n != "." && n != "..") {
edit.Add();
edit.Top() <<= n;
Why does the last line use operator<<= instead of operator= ?
If there's no reason then it should be changed to operator= because it took me a while to track down the fact that it seems to go through Ctrl::operator<<= which goes through the SetData virtual function into EditField::SetData. For a newcomer or even not for a newcomer, it's not easy to find what that operator<<= does - it doesn't make any sense to use it in an example.
Also, why does the above code do an unnecessary call to the Top() function - couldn't it just be edit.Add() = n;
And lastly (off topic but related to the edit.Add function call), does U++ assume that memory allocation with new never fails - how does U++ handle failure?
Graeme
|
|
|
Goto Forum:
Current Time: Mon Apr 29 17:22:10 CEST 2024
Total time taken to generate the page: 0.03299 seconds
|