here's something I am not to clear about:
In C++ when passing values to a function we can pass values by
"reference" like so:
int foo(int& int&); // prototype for foo()
main()
{
int x = 10;
int y = 20;
int result;
result = foo(x, y); // The values of x and y passed to
}
And foo() defined as:
int foo(int& a, int& b)
{
int value;
...
return value;
}
One possible advantage to passing values this way is that in addition
to returning a value to main() side effects are produced,i.e. if foo()
modifies a or b the change will be reflected in the values of x or y
in main, if such effects are desired.
Pretty much the same effect can be easilly acheived via passing
arguments as pointers (which is how I normally go about such a thing).
My main 2 questions are:
1) What is the overall advantage of passing arguments this way (by
reference), as oppsoed to using pointers , and,
2) When passing values this way what is actually being passed to foo()
?? Is it the address of x & y (which would imply pretty much the same
as using a pointer), or an alias which references the adress of the
args passed to foo()???
Any info is appreciated....
Sincerely,
/John <[EMAIL PROTECTED]>
--
email: [EMAIL PROTECTED]
Local mailserver <landreau.ruffe.edu> , remote <ns.computer.net>
Should a gentleman offer, a Tiparillo to a lady?