need help with c++
|
Author |
Message |
u_c_taker
hacks=drama
Posts: 3,185.2011 Threads: 102
Joined: 29th Jan 2007
Reputation: -1.03084
E-Pigs: 36.7855
|
need help with c++
i was just learning c++ but i didnt understand the concept of function calling by name and by reference could anyone give me breif description or a link to a good c++ guide
|
|
19/04/2007 09:58 AM |
|
_VEndeTta
Endless Night
Posts: 522.1732 Threads: 48
Joined: 9th Apr 2007
Reputation: -3.19624
E-Pigs: 4.8849
|
RE: need help with c++
When you Pass by Name your function simply copies the values you pass
into different variables and uses those for calculations, your original values/data
will always remain untouched because your function is using only the copies.
When you Pass by Reference the function will use the actual data you pass in,
so any changes made to them during the function will remain for the rest of the program.
i.e.
void blah(int A)
{
A = 5000
}
void blah2(int &A)
{
A = 5000
}
the second will result in A being set equal to 5000,
the first will result in nothing. It will copy A, set that
copy equal to 5000 and then exit.
Fore example,
And when you gaze long into an abyss,
the abyss gazes also into you.
(This post was last modified: 19/04/2007 10:40 AM by _VEndeTta.)
|
|
19/04/2007 10:33 AM |
|
u_c_taker
hacks=drama
Posts: 3,185.2011 Threads: 102
Joined: 29th Jan 2007
Reputation: -1.03084
E-Pigs: 36.7855
|
RE: need help with c++
yeah thanks its more clear now
|
|
20/04/2007 09:49 AM |
|
User(s) browsing this thread: 1 Guest(s)