functions - pass by reference - pass by pointer - increment++ issue
I decided to learn a little more about passing values to functions via a pretty thorough C++ tutorial. So, using the onlinecompiler.net compiler, I wrote a simple program to call two identical functions. The difference between the 2 is one uses pass by reference, one pass by address.
I have already used this construct in my first (almost complete) C program.
int func (TCHAR* st1, TCHAR* st2, TCHAR* st3, int *start, int *end)
*start = somelocallydefinedint;
-----------------------------
main ()
int start, end;
x = func (st1, st2, st3, &start, &end);
----------------------------
During my test of today, I found that:
*start++;
does not work as expected. Seems I need:
(*start)++;
Which is ironic in that I have one function in my current program that receives a pointer to a WIN32_FIND_DATA struct and in that, the (*struct).fieldinsidestruct syntax must be used.
So, the other way:
int func (........, int &start, int &end)
seems to have the advantage in that, within the function, I don't have to use pesky asterisks and I can also do a start++ with no issues.
The question then becomes: for integers, is there any reason to use the first example of * references vs. the latter, seemingly more concise, & references?