It is cleaner like this:
Qt Code:
Switch view
Tree blah = apple->tree();
Even if it is Tree& blah = apple->tree();
I would disagree it is cleaner code.
If you use pointers, you know you are modifying something which you haven't created. But in case of reference it is hard to know.
Also if references are returned, I would prefer to use it on left hand side. For eg if you have QList<int> numbers;
Then having a reference with [] operator,,,, I can assign value like - numbers[index] = 10;
Lets say I wrote code like -
int & temp = numbers[index];
...
... // assume you have many lines of code here...
temp = 10; // Can you still know you are actually modifying something ? oops ,, did you forget ?
// numbers[index] = 10; // with this line you know you are modifying something..
int & temp = numbers[index];
...
... // assume you have many lines of code here...
temp = 10; // Can you still know you are actually modifying something ? oops ,, did you forget ?
// numbers[index] = 10; // with this line you know you are modifying something..
To copy to clipboard, switch view to plain text mode
Rest depends on personal choice
Bookmarks