Re: passing linked lists to functions
From: Unforgiven (jaapd3000_at_hotmail.com)
Date: 11/26/03
- Next message: Zenon: "Re: Difficulty with nested template classes (newbie)"
- Previous message: Rolf Magnus: "Re: passing linked lists to functions"
- In reply to: Victor Bazarov: "Re: passing linked lists to functions"
- Next in thread: Rolf Magnus: "Re: passing linked lists to functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 26 Nov 2003 23:28:08 +0100
Victor Bazarov wrote:
>> I think that's working but I have another problem: I need to pass two
>> iterators also to this function which point to certain position in
>> the list, should these iterators be passed by reference. The above
>> syntax gives me syntax errors:
>> This is the call from main:
>> qhull(S1, index1, hull, hull.begin(), hull.end(), globalMin,
>> globalMax, rank,
>> numtasks);
>
> 'begin' and 'end' members return a _temporary_ iterator, which cannot
> be passed where a _non_const_ reference is expected. Change your
> 'qhull' function to accept " list<PARTICLE>::iterator const& " for
> both 'iter1' and 'iter2' arguments, and it will work.
That doesn't sound like a good idea to me, because you wouldn't be able to
call any non-const members, and I suppose (especially since his example call
uses begin() and end()) that he's going to want to use operator++, which is
non-const. Just pass the iterators by value, that should do the trick.
-- Unforgiven "You can't rightfully be a scientist if you mind people thinking you're a fool."
- Next message: Zenon: "Re: Difficulty with nested template classes (newbie)"
- Previous message: Rolf Magnus: "Re: passing linked lists to functions"
- In reply to: Victor Bazarov: "Re: passing linked lists to functions"
- Next in thread: Rolf Magnus: "Re: passing linked lists to functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|