| | |
Passing Variables/Parameters - By Ref/Value?
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
![]() |
•
•
Join Date: Apr 2005
Posts: 3
Reputation:
Solved Threads: 0
Hi there
I wonder if anyone can help out a newbie. I am trying to understand the difference between passing variables by reference or value. This is what I understand so far:
1. Passing parameters by value is when the variable is copied into the parameter list of a function or procedure. The value is independent and remains unchanged when passed.
2. Passing parameters by reference is when a value being passed is linked to the original value. THis means that the original value can be altered.
I am not sure on what occasion you would use what and for what reasons...I would be really grateful if someone could explain this to me...
Thanks in advance!
Potsuki
I wonder if anyone can help out a newbie. I am trying to understand the difference between passing variables by reference or value. This is what I understand so far:
1. Passing parameters by value is when the variable is copied into the parameter list of a function or procedure. The value is independent and remains unchanged when passed.
2. Passing parameters by reference is when a value being passed is linked to the original value. THis means that the original value can be altered.
I am not sure on what occasion you would use what and for what reasons...I would be really grateful if someone could explain this to me...
Thanks in advance!
Potsuki
•
•
Join Date: May 2005
Posts: 13
Reputation:
Solved Threads: 0
hi potsuki
well........almost all exams of c or programming
language had asked this question...........
well to begin with call by value.
it is used when u don't want to
change the contents of a variable permanently
well to understand this u 1st have 2 understand the
concept of pointers or memory locations..........
in call by value u ar passing the copy of variable
changing it in the called fuction doesn't effect the memory loaction of
the variable.........but in case of the call by refrence u r passing the
address of the variable......so any change wud b a permanent change
as u practice more u wud urself understand when 2 use which 1.
frank
well........almost all exams of c or programming
language had asked this question...........
well to begin with call by value.
it is used when u don't want to
change the contents of a variable permanently
well to understand this u 1st have 2 understand the
concept of pointers or memory locations..........
in call by value u ar passing the copy of variable
changing it in the called fuction doesn't effect the memory loaction of
the variable.........but in case of the call by refrence u r passing the
address of the variable......so any change wud b a permanent change
as u practice more u wud urself understand when 2 use which 1.
frank
![]() |
Similar Threads
- Problem passing variables to thread (Perl)
- function passing variables (C)
- passing variables threw query (MySQL)
- Passing variables into form fields (PHP)
- need help with code (C++)
- passing arrays in visual basic (Visual Basic 4 / 5 / 6)
Other Threads in the Computer Science Forum
- Previous Thread: Is variable++ 1 atomic action?
- Next Thread: Programming Language required
Views: 6715 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Computer Science
ai algorithm algorithms amazon assignment assignmenthelp assignments battery bigbrother binary bittorrent bletchleypark blogging bomb business clueless codebreaker compiler computer computers computerscience computertrackingsoftware conversion csc data dataanalysis dataintepretation development dfa dissertation dissertationtopic ebook employment energy extensions floatingpoint foreclosure foreclosuresoftware fuel geeks givemetehcodez government hardware homeowners homework homeworkassignment homeworkhelp ibm idea ideas internet iphone ipod itcontracts jobs kindle laser laws lazy linkbait lsmeans mainframes marketing mining mobileapplication nano netbeans networking news os p2p parser piracy piratebay programming rasterizer research sam-being-cute sas science security simulation software spoonfeeding spying sql stephenfry student study supercomputer supercomputing sweden syntactic technology textfield tree two'scompliment uk virus ww2





