int * z=&w; // z is a pointer to int; we assign to it an address of int variable w
If we write:
w = *z;
(that we could read as: " w is equal to value, pointed by z "), variable w would take the value 25, since z is 1776, and the value pointed by 1776 is 25.
You must clearly differentiate that the expression zrefers to the value 1776, while *z (with an asterisk * preceding the identifier) refers to the value stored at address 1776, which in this case is 25.
A pointer may be assigned the value 0 (called the NULL pointer). The NULL pointer is used for initializing pointers. NULL is a standard (predefined) C++ constant.
Нам важно ваше мнение! Был ли полезен опубликованный материал? Да | Нет
studopedia.su - Студопедия (2013 - 2024) год. Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав!Последнее добавление