Pointer
Указатель
In programming, a pointer holds the address of an object in memory, letting code access that object without copying it. A pointer can also be null, meaning it points to nothing.
The address is not the object
Suppose score is an integer variable containing 10. An integer pointer can hold the address of score, but it does not hold the number 10 itself. That distinction matters when you copy a pointer: you get another way to reach the same object, not a separate object with the same value.
Reading pointer code in C++
In int* p, the type int* means “pointer to an int.” Use &score to take the address of score and *p to access the object at the address stored in p. Accessing an object this way is called dereferencing. When reading an assignment, look at its left-hand side: p = &backup changes where the pointer points; *p = 20 writes to the object it currently points to.
int score = 10;
int backup = 0;
int* p = &score;
int* q = p;
*q = 20; // score is now 20; backup is still 0.
q = &backup; // Only q changes. p still points to score.
The same rule applies to a function that takes an int* parameter by value. The function receives a copy of the pointer, so assigning to the parameter does not change the caller's pointer variable. Writing through the parameter can still change the caller's object.
Where pointers show up
A linked-list node can store a pointer to the next node and use nullptr to mark the end of the list. APIs that work with buffers often take a pointer to the first element and a separate length. The pointer tells the function where to start, not how many elements it can access. In C++, pointer arithmetic can step through an array: p + 1 points to the next element when there is one. A pointer just past the last element can mark the end, but dereferencing it is not allowed.
Null, dangling, and ownership
A null pointer deliberately points to nothing. A dangling pointer may be non-null, but the object it referred to is no longer available, for example because a local variable went out of scope. Reading or writing through either kind of pointer has undefined behavior in C++; a crash is not guaranteed. Checking for null does not check the object's lifetime.
A raw pointer such as Widget* also doesn't tell you who is responsible for destroying the object. In modern C++, std::unique_ptr<Widget> expresses exclusive ownership and destroys the object it owns when the owner is destroyed. A raw pointer obtained from it can provide non-owning access, but that raw pointer does not keep the object alive.
What interviewers look for
Expect to trace a short snippet that copies a pointer, reassigns it, or uses one after a function returns. Keep two questions separate: which object does each pointer refer to, and is that object still alive when the code accesses it?