Quote Originally Posted by mickey View Post
I'm sorry but I had change it in the second manner (vector<Node>**) and now I try to change into original version to see the error:now it works. Could be a temporary .net problem (restart it I mean) ???
I found the "*&" in Thinking in c++; why doesn't it "ok"? Does have any sense all or it shuold be better in main() declare vecNode on the stack instead on heap?
thanks
(if problem arise again I update post)
*& idiom is used to pass the pointer as reference. That is the pointer passed from the caller is also modified. This is usually used to return multiple values allocated on heap. I think it is ok to use it.
Usually it is better to declare elements on stack rather that heap but it does depend on how you use it in you application.

Here is a small example i tried to assert my assumption.
Qt Code:
  1. void create(int *t)
  2. {
  3. t = new int(2);
  4. }
  5.  
  6. void createRef(int *&t)
  7. {
  8. t = new int(2);
  9. }
  10.  
  11. int main()
  12. {
  13. int *h, *k;
  14. h = k = 0;
  15. create(h);
  16. Q_ASSERT(h != 0); // fails
  17. createRef(k);
  18. Q_ASSERT(k != 0); // succeeds.
  19. return 0;
  20. }
To copy to clipboard, switch view to plain text mode