On 2007-08-13 10:42, arnuld wrote:
>> On Aug 13, 1:40 pm, arnuld <geek.arn...@gmail.com> wrote:
>> i changed code to this:
>
>> ........[SNIP].......
>
>> WHAT IS THIS ?
>
> i mean why i dis not get 2 values as output ?
C++ only allows one return value, however by using references or
pointers you can let the function modify variables in the scope of the
caller, thus simulating more return values.
> BTW, when i try to print "write_temp", i always get 0 (zero).. ???
Probably because you are trying to print it like this:
std::cout << "---------------------------\n"
<< *find_val( begin, end, find_value, write_temp )
<< " " << write_temp << std::endl;
The problem with this statement is that the order of evaluation is
unspecified, so write_temp can be evaluated before the call to
find_val(), in which case it will be 0. Make sure to call the function
and print the value of write_temp in two different statements.
--
Erik Wikström