Summary
Section 8.2 Pointer Variable Declarations and Initialization
Pointers are variables that contain as their values memory addresses of other variables.
The declaration
int* ptr;
declares
ptr
to be a pointer to a variable of typeint
and is read, “ptr
is a pointer toint
.” The*
as used here in a declaration indicates that the variable is a pointer.You can initialize a pointer with an address of an object of the same type or with
nullptr
(p. 342).The only integer that can be assigned to a pointer without casting is
0
.
Section 8.3 Pointer Operators
The
&
(address) operator (p. 342) obtains the memory address of its operand.The operand of the address operator must be a variable name (or another lvalue); the address operator cannot ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.