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 #445291 is a reply to message #445206] Fri, 25 March 2011 14:30 Go to previous messageGo to previous message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma:
General (1 Star)
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;
}


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg
 
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 May 22 21:48:51 MST 2024

Total time taken to generate the page: 3.35361 seconds