Ampersand differences
Hello, I am very new to C++ and am just learning.
If I were to declare variable as this:
1 2 3
|
int a = 7
int b = 6
int* c = &b
|
This would simply mean that c = 6, correct? c has a reference to b.
But now I get more confused with this ampersand:
1 2 3 4
|
void test( int& x, int y, int*& z )
x++;
y++;
z= &a;
|
I get that when you have an & in parameters, it becomes reference parameters. But the part with int*& z confuses me. What does the *& together mean?
Thanks in advance!
int x = 10;
int &rx = x;
Here rx is reference to x of type int.
int *p = 0;
int * &rp = p;
Here rp is reference to p of type int *.
This would simply mean that c = 6, correct? c has a reference to b. |
No. c is a pointer to b. *c == 6.
I get that when you have an & in parameters, it becomes reference parameters. But the part with int*& z confuses me. What does the *& together mean? |
It means it's a reference to a pointer.
Topic archived. No new replies allowed.