Why do you have to add & sign when initialising a pointer

closed account (EwCjE3v7)
Why do you have to add & sign when initialising a pointer.
Like the &sign is for a reference. Right? Why do you have to make a reference to initialise or assign a pointer

1
2
3
4
5
6
7
8
#include <iostream>
int main()
{
 int val = 0;
 int *p = &val;
 std::cout << *p << std::endl;
 return 0;
}
closed account (EwCjE3v7)
Oh sry I found the answer:A pointer holds the address of another object. We get the address of an object by usin the address-of operator (the & operator)

Sry :(

Topic archived. No new replies allowed.