pointer pointer pointer
hey guys, here is a code of pointer
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
void test(int* i)
{
*i = 2;
}
int main()
{
int x = 3;
test(&x);
std::cout << x;
}
|
notice
that is need.
so, how do I make it into
that is alot more convenient as a function.
this young beginner will be glad even if it's just a little help
Use a reference.
1 2 3 4 5 6 7 8 9 10 11
|
void test(int& i)
{
i = 2;
}
int main()
{
int x = 3;
test(x);
std::cout << x;
}
|
thanks, been looking for that in a long long time
Topic archived. No new replies allowed.