pointers

Posts 16–18 of 18 · Page 2 of 2
Quote Originally Posted by 'Bruno View Post
yea (e.g)... without needing to return (attention that arrays wont need it.. for the reason already talked about on the other topic)
ok I got it now! thanks a lot
Quote Originally Posted by VvITylerIvV View Post
I know what you mean... Earlier in the day I'm nice... then at night I can be a bit of a b****


which would be helpful how?
Code:
int myLeetVar = 1;

void setLeet(int leet)
{
    leet = 1337;
}

int main()
{
    setLeet(myLeetVar);
    cout<<myLeetVar;
}
outputs: 1

Code:
int myLeetVar = 1;

void setLeet(int *leet)
{
    *leet = 1337;
}

int main()
{
    setLeet(myLeetVar);
    cout<<myLeetVar;
}
outputs: 1337

Useful for game classes etc
Quote Originally Posted by Hell_Demon View Post
Code:
int myLeetVar = 1;

void setLeet(int leet)
{
    leet = 1337;
}

int main()
{
    setLeet(myLeetVar);
    cout<<myLeetVar;
}
outputs: 1

Code:
int myLeetVar = 1;

void setLeet(int *leet)
{
    *leet = 1337;
}

int main()
{
    setLeet(myLeetVar);
    cout<<myLeetVar;
}
outputs: 1337

Useful for game classes etc
Ok thank you, I understand it now... Pointers are helpful when used in functions to change the value of a variable outside of the function?
Posts 16–18 of 18 · Page 2 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us