« first day (1624 days earlier)      last day (804 days later) » 

10:46 AM
First!
For discussions on Minecraft Forge, use this other room: Minecraft Forge API
 
 
8 hours later…
6:20 PM
Guys
 
and girls
don't be sexist
 
I'm understanding pass by reference
#include <iostream>

using namespace std;


int fun(int &x) {

    return x*5;

}

int arr[3] = {1, 2, 3};

int main() {

    for(int i=0; i < 3; i++) {
        fun(arr[i]);
        cout<<arr[i]<<endl;
    }

}
 
@underscore then what's the problem? :p
 
why this doesn’t output 5,10,15 ?
 
Why not ask on Stack Overflow?
 
6:22 PM
@underscore why would it?
 
@underscore you return x*5. that does not change x.
 
you never change x
you return a value which you never use
G.G.
someone bin code pl0x
 
return x = x*5;
#include <iostream>
using namespace std;
int fun(int &x) {
    return x = x*5;
}
int arr[3] = {1, 2, 3};
int main() {
    for(int i=0; i < 3; i++) {
        fun(arr[i]);
        cout<<arr[i]<<endl;
    }
}
 
16 messages moved from Lounge<C++>
 

« first day (1624 days earlier)      last day (804 days later) »