Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Technical Support » Other » Need help with my C++ code
Re: Need help with my C++ code [message #445308 is a reply to message #445291] Sat, 26 March 2011 11:32 Go to previous messageGo to previous message
_SSnipe_ is currently offline  _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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: need help with php
Next Topic: Is it possible to replace the CPU Fans on laptops?
Goto Forum:
  


Current Time: Wed Jun 19 11:54:18 MST 2024

Total time taken to generate the page: 0.00816 seconds