| | |
Will somebody please explain value parameters to me!!!
![]() |
There are generally two kinds of parameters to a function, those by VALUE and those by REFERENCE. A VALUE parameter is one where the variable's value (it's contents) are passed to the routine, whereas a REFERENCE parameter is one where the variable's location is passed to the routune.
Here's an example:
Here's an example:
C Syntax (Toggle Plain Text)
void Test( int byValue, int& byReference ) { byValue++; // this changes the local version, but doesn't affect the caller byReference++; // this changes the caller's variable too printf( "inside TEST value=%d, ref=%d\n", byValue, byReference ); // this prints 2 for both since they were passed in as 1 in our call shown below... } ... int byValue = 1, byReference = 1; Test( byValue, byReference ); printf( "after TEST value=%d, ref=%d\n", byValue, byReference ); // this prints 1 and 2, because Test() changed the byReference one but not the byValue one.
![]() |
Similar Threads
- program that starts another program. (C++)
- How methods with multiple parameters are declared. (Java)
- SQL/XML Query (XML, XSLT and XPATH)
- Doubt on memcpy dump (C++)
- Passing Variables/Parameters - By Ref/Value? (Computer Science)
- Parameters order (Java)
- DOS C++, pulling boot order and hard drive parameters, (C++)
Other Threads in the C Forum
- Previous Thread: What does this bit of code accomplish?
- Next Thread: what is fflush?
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o include incrementoperators input interest kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open openwebfoundation owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h





