+ 1
What is different between "&" and "*" to declare a pointer?
4 Answers
+ 11
& is the address-of operator.
* is the point-to operator.
int *r = 0;
int s = 0;
// declaring a pointer and a variable.
r = &s;
// assign address of s to r.
cout << *r;
// tells program to print whatever the address stored in r points to.
+ 8
In
int &p;
The "&" here isn't used as a operator. It denotes a reference instead of a pointer to an object.
I suggest you to take a look at the differences between a pointer and a reference.
https://www.quora.com/What-are-the-differences-between-references-and-pointers
+ 1
what is:
int &p;
+ 1
tnx