Re: Need help with my C++ code [message #445308 is a reply to message #445291] |
Sat, 26 March 2011 11:32 |
_SSnipe_
Messages: 4121 Registered: May 2007 Location: Riverside Southern Califo...
Karma:
|
General (4 Stars) |
|
|
Omar007 wrote on Fri, 25 March 2011 14:30 | I'm not a C++ master nor am I writing this down with any reference. This is from the top of my head so it may contain faulty information.
---
A call by value makes a duplicate and does not affect the original.
Call by reference modifies the original value you pass.
Call by value
void main()
{
int a = 10;
somefunction(a);
cout << a; //10
}
void somefunction(int a)
{
a = 20;
}
Call by reference
void main()
{
int a = 10;
somefunction(a);
cout << a; //20
}
void somefunction(int& a)
{
a = 20;
}
|
See, that makes much more scene, thanks
Another problem I am having is I am lost on the difference between a functions formal parameters and arguments
|
|
|