0
Can someone please explain this code? I'm having confusion with the output ?
#include <iostream> using namespace std; int main() { int score = 4; cout << &score << endl; return 0; } output: 0×28ff1c
5 Respostas
+ 2
"&" operator is used to access the address of a variable.
That number you see is just the location where the variable is stored in memory.
+ 1
& operator is used when working with pointers and when passing arguments to a function by reference.
eg-
int a = 5;
int *p = &a; // now p is pointing to a
+ 1
& is called the address operator.
Int number=3;
Cout<<&number;
Would print out a random number with letters. This is because you printed the address where number is stored in stack. Like mention before by others the address operator & is used when working with pointers to point at a specifically location.
0
remove the '&' sign.
0
what's the point in learning & operator if we remove it?