Function call

hello All,

I would like to understand what is the differnt between both of following calls -
Get(arr, size, find) = 13;
Get(arr, size, find);
what is mean that the function equal to 13 ?

thanks
The function could return a reference, in which case whichever variable it is a reference to would be set equal to 13.

A little more context would be useful.


Here's a possible example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;

int & Get( int *array, int size, int find )
{
   for ( int i = 0; i < size; i++ )
   {
      if ( array[i] == find ) return array[i];
   }
   return array[0];
}

int main()
{
   int a[] = {1, 2, 3, 4, 5 };
   for ( int e : a ) cout << e << ' ';
   cout << '\n';

   Get( a, 5, 3 ) = 13;
   for ( int e : a ) cout << e << ' ';
   cout << '\n';
}
1 2 3 4 5 
1 2 13 4 5 
Last edited on
Topic archived. No new replies allowed.